Encoding.GetEncodings Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns an array that contains all encodings.

Namespace:   System.Text
Assembly:  mscorlib (in mscorlib.dll)

static member GetEncodings : unit -> EncodingInfo[]

Return Value

Type: System.Text.EncodingInfo[]

An array that contains all encodings.

This method returns a list of supported encodings, uniquely distinguished by code page. For a table that lists the supported encodings, see the Encoding class topic.


The list of supported encodings returned by the GetEncodings method does not include any additional encodings made available by any EncodingProvider implementations that were registered by calls to the RegisterProvider method.

Encodings 50220 and 50222 are both associated with the name "iso-2022-jp", but they are not identical. Encoding 50220 converts half-width Katakana characters to full-width Katakana characters, whereas encoding 50222 uses a shift-in/shift-out sequence to encode half-width Katakana characters. The display name for encoding 50222 is "Japanese (JIS-Allow 1 byte Kana - SO/SI)" to distinguish it from encoding 50220, which has the display name "Japanese (JIS)".

If you request the encoding name "iso-2022-jp", the .NET Framework returns encoding 50220. However, the encoding that is appropriate for your app depends on the preferred treatment of the half-width Katakana characters.

To get a specific encoding, you should use the GetEncoding method.

GetEncodings is sometimes used to present the user with a list of encodings in a File Save as dialog box. However, many non-Unicode encodings are either incomplete and translate many characters to "?", or have subtly different behavior on different platforms. Consider using UTF-8 or UTF-16 as the default.

The following example checks the values of the Boolean properties of each encoding.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top