EncodingProvider Class
Provides the base class for an encoding provider, which supplies encodings that are unavailable on a particular platform.
Assembly: mscorlib (in mscorlib.dll)
| Name | Description | |
|---|---|---|
![]() | EncodingProvider() | Initializes a new instance of the EncodingProvider class. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetEncoding(Int32) | Returns the encoding associated with the specified code page identifier. |
![]() | GetEncoding(Int32, EncoderFallback^, DecoderFallback^) | Returns the encoding associated with the specified code page identifier. Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded. |
![]() | GetEncoding(String^) | Returns the encoding with the specified name. |
![]() | GetEncoding(String^, EncoderFallback^, DecoderFallback^) | Returns the encoding associated with the specified name. Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded. |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
An encoding provider supplies encodings that are not otherwise available on a particular target platform.
The .NET Framework on the Windows desktop supports a large number of character encodings and code pages. You can get a complete list of encodings available in the .NET Framework on the Windows desktop by calling the Encoding::GetEncodings method. .NET Core, on the other hand, by default supports only the following encodings:
ASCII (code page 20127), which is returned by the Encoding::ASCII property.
ISO-8859-1 (code page 28591).
UTF-7 (code page 65000), which is returned by the Encoding::UTF7 property.
UTF-8 (code page 65001), which is returned by the Encoding::UTF8 property.
UTF-16 and UTF-16LE (code page 1200), which is returned by the Unicode property.
UTF-16BE (code page 1201), which is instantiated by calling the UnicodeEncoding::UnicodeEncoding(Boolean, Boolean) or UnicodeEncoding::UnicodeEncoding(Boolean, Boolean) constructor with a bigEndian value of true.
UTF-32 and UTF-32LE (code page 12000), which is returned by the Encoding::UTF32 property.
UTF-32BE (code page 12001), which is instantiated by calling an UTF32Encoding constructor that has a bigEndian parameter and providing a value of true in the method call.
In .NET Framework 4.6, EncodingProvider is the base class that makes otherwise unavailable encodings available to the .NET Framework. This involves the following steps:
Define a subclass of EncodingProvider that overrides the two abstract GetEncoding overloads, GetEncoding(Int32) and GetEncoding(String^). These overloads return the otherwise unsupported encoding by code page identifier and by name.
Optionally, you can override the virtual GetEncoding(Int32, EncoderFallback^, DecoderFallback^) and GetEncoding(String^, EncoderFallback^, DecoderFallback^) methods. In most cases, this is not necessary, since the base class provides a default implementation.
Pass the EncodingProvider instance to the Encoding::RegisterProvider method to make the encodings supplied by the EncodingProvider object available to the common language runtime.
Call an Encoding::GetEncoding overload to retrieve the encoding. The Encoding::GetEncoding method will call the corresponding EncodingProvider::GetEncoding to determine whether it can supply the requested encoding.
The .NET Framework Class Library provides one static property, CodePagesEncodingProvider::Instance, that returns an EncodingProvider object that makes the full set of encodings available on the desktop .NET Framework Class Library available to .NET Core applications. In addition, you can derive from the EncodingProvider class to make your own encodings available.
Available since 10
.NET Framework
Available since 4.6
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

