CodePagesEncodingProvider.Instance Свойство
Определение
Возвращает поставщик кодировки для кодовых страниц, поддерживаемых платформой .NET Framework для настольных систем, но не текущей платформой .NET Framework.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; }
member this.Instance : System.Text.EncodingProvider
Public Shared ReadOnly Property Instance As EncodingProvider
Значение свойства
Поставщик кодирования, который разрешает доступ к кодировкам, не поддерживаемым на текущей .NET Frameworkной платформе.An encoding provider that allows access to encodings not supported on the current .NET Framework platform.
Комментарии
.NET Framework поддерживает большое количество кодировок символов и кодовых страниц.The .NET Framework supports a large number of character encodings and code pages. Полный список кодировок можно получить, вызвав Encoding.GetEncodings метод, который доступен в .NET Framework.You can get a complete list of encodings by calling the Encoding.GetEncodings method, which is available in the .NET Framework. С другой стороны, .NET Core поддерживает только следующие кодировки по умолчанию:On the other hand, .NET Core only supports the following encodings by default:
ASCII (кодовая страница 20127), возвращаемая Encoding.ASCII свойством.ASCII (code page 20127), which is returned by the Encoding.ASCII property.
ISO-8859-1 (кодовая страница 28591).ISO-8859-1 (code page 28591).
UTF-7 (кодовая страница 65000), возвращаемая Encoding.UTF7 свойством.UTF-7 (code page 65000), which is returned by the Encoding.UTF7 property.
UTF-8 (кодовая страница 65001), возвращаемая Encoding.UTF8 свойством.UTF-8 (code page 65001), which is returned by the Encoding.UTF8 property.
UTF-16 и UTF-16LE (кодовая страница 1200), возвращаемая Encoding.Unicode свойством.UTF-16 and UTF-16LE (code page 1200), which is returned by the Encoding.Unicode property.
UTF-16BE (кодовая страница 1201), экземпляр которой создается путем вызова UnicodeEncoding.UnicodeEncoding конструктора или UnicodeEncoding.UnicodeEncoding со
bigEndian
значениемtrue
.UTF-16BE (code page 1201), which is instantiated by calling the UnicodeEncoding.UnicodeEncoding or UnicodeEncoding.UnicodeEncoding constructor with abigEndian
value oftrue
.UTF-32 и UTF-32LE (кодовая страница 12000), возвращаемая Encoding.UTF32 свойством.UTF-32 and UTF-32LE (code page 12000), which is returned by the Encoding.UTF32 property.
UTF-32BE (кодовая страница 12001), экземпляр которой создается путем вызова UTF32Encoding конструктора, который имеет
bigEndian
параметр и предоставляет значениеtrue
в вызове метода.UTF-32BE (code page 12001), which is instantiated by calling an UTF32Encoding constructor that has abigEndian
parameter and providing a value oftrue
in the method call.
Чтобы получить кодировку, имеющуюся в .NET Framework на рабочем столе Windows, но не в .NET Core, выполните следующие действия.To retrieve an encoding that is present in the .NET Framework on the Windows desktop but not in .NET Core, you do the following:
Добавьте в проект ссылку на сборку System.Text.Encoding.CodePages.dll.Add a reference to the System.Text.Encoding.CodePages.dll assembly to your project.
Получите EncodingProvider объект из статического CodePagesEncodingProvider.Instance Свойства.Get the EncodingProvider object from the static CodePagesEncodingProvider.Instance property.
Передайте EncodingProvider объект Encoding.RegisterProvider методу, чтобы сделать кодировки, предоставляемые EncodingProvider объектом, доступными среде CLR.Pass the EncodingProvider object to the Encoding.RegisterProvider method to make the encodings supplied by the EncodingProvider object available to the common language runtime.
Вызовите Encoding.GetEncoding перегрузку для получения кодировки.Call an Encoding.GetEncoding overload to retrieve the encoding. Encoding.GetEncodingМетод вызывает соответствующий EncodingProvider.GetEncoding метод, чтобы определить, может ли он предоставить запрошенную кодировку.The Encoding.GetEncoding method will call the corresponding EncodingProvider.GetEncoding method to determine whether it can supply the requested encoding.