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
ByteOrderMark

Methods

Decode(Byte[])

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

public static Encoding Decode(byte[] bytes)

Parameters

bytes Byte[]

The byte[] to be converted into an Encoding.

Returns

Encoding

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

Exceptions

ArgumentNullException

bytes cannot be null.

ArgumentException

bytes was without byte order mark information (BOM).

DetectEncodingOrDefault(Byte[], Encoding)

Tries to detect an 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 Encoding.

fallbackEncoding Encoding

The 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 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 Stream to parse for an Encoding.

fallbackEncoding Encoding

The 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 Byte array without preamble information.

Remove(Stream, Encoding, Action<DisposableOptions>)

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

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

Parameters

value Stream

The 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 Stream without preamble information.

TryDetectEncoding(Byte[], out Encoding)

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

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

Parameters

input Byte[]

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

result Encoding

When this method returns, it contains the Unicode 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 Encoding.

Returns

Boolean

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

TryDetectEncoding(Stream, out Encoding)

Tries to resolve the Unicode Encoding object from the specified Stream object.

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

Parameters

value Stream

The Stream object to resolve the Unicode Encoding object from.

result Encoding

When this method returns, it contains the Unicode 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 Encoding.

Returns

Boolean

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