EncodingProvider EncodingProvider EncodingProvider EncodingProvider Class

Definition

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

public ref class EncodingProvider abstract
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class EncodingProvider
type EncodingProvider = class
Public MustInherit Class EncodingProvider
Inheritance
EncodingProviderEncodingProviderEncodingProviderEncodingProvider
Derived
Attributes

Remarks

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:

Starting with the .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. Note that you can also choose to return a default encoding if the GetEncoding(Int32) method is called with an argument of 0.

  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.

Constructors

EncodingProvider() EncodingProvider() EncodingProvider() EncodingProvider()

Initializes a new instance of the EncodingProvider class.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEncoding(Int32) GetEncoding(Int32) GetEncoding(Int32) GetEncoding(Int32)

Returns the encoding associated with the specified code page identifier.

GetEncoding(Int32, EncoderFallback, DecoderFallback) GetEncoding(Int32, EncoderFallback, DecoderFallback) GetEncoding(Int32, EncoderFallback, DecoderFallback) 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) GetEncoding(String) GetEncoding(String) GetEncoding(String)

Returns the encoding with the specified name.

GetEncoding(String, EncoderFallback, DecoderFallback) GetEncoding(String, EncoderFallback, DecoderFallback) GetEncoding(String, EncoderFallback, DecoderFallback) 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() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also