TextEncodingConverterTryGetEncoding(Int32, Encoding) Method

Tries to return a corresponding Encoding object for the specified code page number.

Definition

Namespace: FolkerKinzel.Strings
Assembly: FolkerKinzel.Strings (in FolkerKinzel.Strings.dll) Version: 9.4.0+10a7d4d71aa960998e32ac0ac6c4fcbe4164c917
C#
public static bool TryGetEncoding(
	int codePage,
	out Encoding?? encoding
)

Parameters

codePage  Int32

The code page number.

  Caution

0 is treated as an invalid argument. This behavior is different from that of the Encoding class.
encoding  Encoding
When this method returns true, contains an Encoding object that matches the specified code page number, null otherwise. This parameter is passed uninitialized.

Return Value

Boolean
true if the conversion was successful, false otherwise.

Remarks

.NET Standard and .NET 5.0 or later only recognize a small number of character sets by default. The method overrides this default.

The properties EncoderFallback and DecoderFallback of the generated Encoding object are set to ReplacementFallback.

See Also