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
Returns
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
EncodingThe Encoding to use when conversion is unsuccessful.
Returns
- Encoding
Either the detected encoding of
input
or thefallbackEncoding
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
Returns
- Encoding
Either the detected encoding of
value
or thefallbackEncoding
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
EncodingThe encoding to use when determining the preamble to remove.
Returns
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
StreamThe Stream to process.
encoding
EncodingThe encoding to use when determining the preamble to remove.
setup
Action<DisposableOptions>The DisposableOptions which may be configured.
Returns
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
EncodingWhen 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 theinput
parameter is null, or does not contain a Unicode representation of an Encoding.
Returns
- Boolean
true
if theinput
parameter was converted successfully; otherwise,false
.
TryDetectEncoding(Stream, out Encoding)
public static bool TryDetectEncoding(Stream value, out Encoding result)
Parameters
value
StreamThe Stream object to resolve the Unicode Encoding object from.
result
EncodingWhen 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 thevalue
parameter is null, or does not contain a Unicode representation of an Encoding.
Returns
- Boolean
true
if thevalue
parameter was converted successfully; otherwise,false
.