Getting the list of supported Encoding types in .NET
October 9, 2017 Leave a comment
Every text file and string is encoded using one of many encoding standards. Normally .NET will handle encoding automatically but there are times when you need to dig into the internals for encoding and decoding. It’s very simple to retrieve the list of supported encoding types, a.k.a code pages in .NET:
EncodingInfo[] codePages = Encoding.GetEncodings(); foreach (EncodingInfo codePage in codePages) { Console.WriteLine("Code page ID: {0}, IANA name: {1}, human-friendly display name: {2}", codePage.CodePage, codePage.Name, codePage.DisplayName); }
Example output:
Code page ID: 37, IANA name: IBM037, human-friendly display name: IBM EBCDIC (US-Canada)
Code page ID: 852, IANA name: ibm852, human-friendly display name: Central European (DOS)
View all posts related to Globalization here.