Table of Contents

Class ByteOrderMark

Namespace
Cuemon.Text
Assembly
Cuemon.Core.dll

Provides a set of static methods for Unicode related operations.

public static class ByteOrderMark
Inheritance
Object
ByteOrderMark

Methods

Decode(Byte[])

Decodes a BOM-preamble of the specified bytes to its equivalent System.Text.Encoding representation.

public static Encoding Decode(byte[] bytes)

Parameters

bytes Byte[]

The byte[] to be converted into an System.Text.Encoding.

Returns

Encoding

An System.Text.Encoding that is equivalent to the BOM-preamble of bytes.

Exceptions

System.ArgumentNullException

bytes cannot be null.

ArgumentException

bytes was without byte order mark information (BOM).

DetectEncodingOrDefault(Byte[], Encoding)

Tries to detect an System.Text.Encoding object from the specified input. If unsuccessful, the fallbackEncoding value is returned. Default is DefaultEncoding.

public static Encoding DetectEncodingOrDefault(byte[] input, Encoding fallbackEncoding)

Parameters

input Byte[]

The byte[] to parse for an System.Text.Encoding.

fallbackEncoding Encoding

The System.Text.Encoding to use when conversion is unsuccessful.

Returns

Encoding

Either the detected encoding of input or the fallbackEncoding encoding.

DetectEncodingOrDefault(Stream, Encoding)

Tries to detect an System.Text.Encoding object from the specified value. If unsuccessful, the fallbackEncoding value is returned.

public static Encoding DetectEncodingOrDefault(Stream value, Encoding fallbackEncoding)

Parameters

value Stream

The System.IO.Stream to parse for an System.Text.Encoding.

fallbackEncoding Encoding

The System.Text.Encoding to use when conversion is unsuccessful.

Returns

Encoding

Either the detected encoding of value or the fallbackEncoding encoding.

Remove(Byte[], Encoding)

Removes the preamble information (if present) from the specified byte[].

public static byte[] Remove(byte[] bytes, Encoding encoding)

Parameters

bytes Byte[]

The bytes byte[] to process.

encoding Encoding

The encoding to use when determining the preamble to remove.

Returns

Byte[]

A System.Byte array without preamble information.

Remove(Stream, Encoding, Action<DisposableOptions>)

Removes the preamble information (if present) from the specified System.IO.Stream.

public static Stream Remove(Stream value, Encoding encoding, Action<DisposableOptions> setup = null)

Parameters

value Stream

The System.IO.Stream to process.

encoding Encoding

The encoding to use when determining the preamble to remove.

setup Action<DisposableOptions>

The DisposableOptions which may be configured.

Returns

Stream

A System.IO.Stream without preamble information.

TryDetectEncoding(Byte[], out Encoding)

Tries to resolve the Unicode System.Text.Encoding object from the specified byte[].

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

Parameters

input Byte[]

The byte[] to resolve the Unicode System.Text.Encoding object from.

result Encoding

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

Returns

Boolean

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

TryDetectEncoding(Stream, out Encoding)

Tries to resolve the Unicode System.Text.Encoding object from the specified System.IO.Stream object.

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

Parameters

value Stream

The System.IO.Stream object to resolve the Unicode System.Text.Encoding object from.

result Encoding

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

Returns

Boolean

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