Table of Contents

TryDetectEncoding Method

Definition

Namespace
Cuemon.Text
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Text/ByteOrderMark.cs

TryDetectEncoding(byte[], out Encoding)

Tries to detect the encoding represented by the byte order mark in the specified byte array.

public static bool TryDetectEncoding(byte[] input, out Encoding result)

Parameters

input byte[]

The byte array to inspect.

result Encoding

When this method returns, contains the detected Encoding if detection succeeds; otherwise, null.

Returns

bool

true if an encoding was detected; otherwise, false.

TryDetectEncoding(Stream, out Encoding)

Tries to detect the encoding represented by the byte order mark in the specified stream.

public static bool TryDetectEncoding(Stream value, out Encoding result)

Parameters

value Stream

The stream to inspect.

result Encoding

When this method returns, contains the detected Encoding if detection succeeds; otherwise, null.

Returns

bool

true if an encoding was detected; otherwise, false.

Remarks

This method reads up to the first four bytes of value and restores the original stream position before returning. The stream must support seeking.