Edytuj

Udostępnij za pośrednictwem


CodePagesEncodingProvider.GetEncoding Method

Definition

Overloads

GetEncoding(Int32)

Returns the encoding associated with the specified code page identifier.

GetEncoding(String)

Returns the encoding associated with the specified code page name.

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 of true.

  • 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 of true in the method call.

To retrieve an encoding that is present in .NET Framework but not in .NET Core, you do the following:

GetEncoding(Int32)

Source:
CodePagesEncodingProvider.cs
Source:
CodePagesEncodingProvider.cs
Source:
CodePagesEncodingProvider.cs

Returns the encoding associated with the specified code page identifier.

public:
 override System::Text::Encoding ^ GetEncoding(int codepage);
public override System.Text.Encoding? GetEncoding (int codepage);
public override System.Text.Encoding GetEncoding (int codepage);
override this.GetEncoding : int -> System.Text.Encoding
Public Overrides Function GetEncoding (codepage As Integer) As Encoding

Parameters

codepage
Int32

The code page identifier of the preferred encoding which the encoding provider may support.

Returns

The encoding associated with the specified code page identifier, or null if the provider does not support the requested codepage encoding.

Applies to

GetEncoding(String)

Source:
CodePagesEncodingProvider.cs
Source:
CodePagesEncodingProvider.cs
Source:
CodePagesEncodingProvider.cs

Returns the encoding associated with the specified code page name.

public:
 override System::Text::Encoding ^ GetEncoding(System::String ^ name);
public override System.Text.Encoding? GetEncoding (string name);
public override System.Text.Encoding GetEncoding (string name);
override this.GetEncoding : string -> System.Text.Encoding
Public Overrides Function GetEncoding (name As String) As Encoding

Parameters

name
String

The code page name of the preferred encoding which the encoding provider may support.

Returns

The encoding associated with the specified code page, or null if the provider does not support the requested encoding.

Applies to