Table of Contents

TryDetectUnicodeEncoding Method

Definition

Namespace
Cuemon.Extensions
Assemblies
Cuemon.Extensions.Core.dll
Source
src/Cuemon.Extensions.Core/ByteExtensions.cs

TryDetectUnicodeEncoding(byte[], out Encoding)

Tries to resolve the Unicode Encoding object from the specified byte array.

public static bool TryDetectUnicodeEncoding(this byte[] bytes, out Encoding result)

Parameters

bytes byte[]

The byte array to extend.

result Encoding

When this method returns, it contains the Unicode Encoding value equivalent to the encoding contained in bytes, if the conversion succeeded, or a null reference (Nothing in Visual Basic) if the conversion failed. The conversion fails if the bytes parameter is null, or does not contain a Unicode representation of an Encoding.

Returns

bool

true if the bytes parameter was converted successfully; otherwise, false.