CodePagesEncodingProvider.Instance Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an encoding provider for code pages supported in the desktop .NET Framework but not in the current .NET Framework platform.
public:
static property System::Text::EncodingProvider ^ Instance { System::Text::EncodingProvider ^ get(); };
public static System.Text.EncodingProvider Instance { get; }
static member Instance : System.Text.EncodingProvider
Public Shared ReadOnly Property Instance As EncodingProvider
Property Value
An encoding provider that allows access to encodings not supported on the current .NET Framework platform.
Remarks
The .NET Framework supports a large number of character encodings and code pages. You can get a complete list of encodings by calling the Encoding.GetEncodings method, which is available in the .NET Framework. On the other hand, .NET Core only supports the following encodings by default:
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 Encoding.Unicode property.
UTF-16BE (code page 1201), which is instantiated by calling the UnicodeEncoding.UnicodeEncoding or UnicodeEncoding.UnicodeEncoding constructor with a
bigEndian
value oftrue
.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 oftrue
in the method call.
To retrieve an encoding that is present in the .NET Framework but not in .NET Core, you do the following:
Get the EncodingProvider object from the static CodePagesEncodingProvider.Instance property.
Pass the EncodingProvider object 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 method to determine whether it can supply the requested encoding.