Provides the base class for an encoding provider, which supplies encodings that are unavailable on a particular platform.
public ref class EncodingProvider abstract
public abstract class EncodingProvider
[System.Runtime.InteropServices.ComVisible(true)] public abstract class EncodingProvider
type EncodingProvider = class
Public MustInherit Class EncodingProvider
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
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
bigEndianparameter and providing a value of
truein the method call.
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:
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.
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.
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.
Initializes a new instance of the EncodingProvider class.
Determines whether the specified object is equal to the current object.(Inherited from Object)
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.
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.
Serves as the default hash function.(Inherited from Object)
Gets the Type of the current instance.(Inherited from Object)
Creates a shallow copy of the current Object.(Inherited from Object)
Returns a string that represents the current object.(Inherited from Object)