TextEncodingConverterTryGetEncoding(Int32, EncoderFallback, DecoderFallback, Encoding) Method

Tries to return a corresponding Encoding object for the specified code page number, whose properties EncoderFallback and DecoderFallback are set to the desired values.

Definition

Namespace: FolkerKinzel.Strings
Assembly: FolkerKinzel.Strings (in FolkerKinzel.Strings.dll) Version: 9.4.0+10a7d4d71aa960998e32ac0ac6c4fcbe4164c917
C#
public static bool TryGetEncoding(
	int codePage,
	EncoderFallback encoderFallback,
	DecoderFallback decoderFallback,
	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.
encoderFallback  EncoderFallback
An object that provides an error handling mechanism if a character cannot be encoded with the Encoding object.
decoderFallback  DecoderFallback
An object that provides an error handling mechanism if a Byte sequence cannot be decoded with the Encoding object .
encoding  Encoding
When this method returns true, contains an Encoding object that matches the specified code page number and whose properties EncoderFallback und DecoderFallback are set to the desired values, 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 higher recognize by default only a small number of character sets. The method overrides this default setting.

Exceptions

ArgumentNullExceptionencoderFallback or decoderFallback is null.

See Also