EncodingProvider Class

.NET Framework (current version)
 

Provides the base class for an encoding provider, which supplies encodings that are unavailable on a particular platform.

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

System::Object
  System.Text::EncodingProvider

[ComVisibleAttribute(true)]
public ref class EncodingProvider abstract 

NameDescription
System_CAPS_pubmethodEncodingProvider()

Initializes a new instance of the EncodingProvider class.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEncoding(Int32)

Returns the encoding associated with the specified code page identifier.

System_CAPS_pubmethodGetEncoding(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.

System_CAPS_pubmethodGetEncoding(String^)

Returns the encoding with the specified name.

System_CAPS_pubmethodGetEncoding(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.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

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:

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:

  1. 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.

  2. 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.

  3. Pass the EncodingProvider instance to the Encoding::RegisterProvider method to make the encodings supplied by the EncodingProvider object available to the common language runtime.

  4. 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.

Universal Windows Platform
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.

Return to top
Show: