C# Class AutoIt.Common.TextEncodingDetect

Exibir arquivo Open project: AutoIt/text-encoding-detect Class Usage Examples

Public Methods

Method Description
CheckBom ( byte buffer, int size ) : Encoding

Checks for a BOM sequence in a byte buffer.

DetectEncoding ( byte buffer, int size ) : Encoding

Automatically detects the Encoding type of a given byte buffer.

GetBomLengthFromEncodingMode ( Encoding encoding ) : int

Gets the BOM length for a given Encoding mode.

Private Methods

Method Description
CheckUtf16Ascii ( byte buffer, int size ) : Encoding

Checks if a buffer contains text that looks like utf16. This is done based on the use of nulls which in ASCII/script like text can be useful to identify.

CheckUtf16NewlineChars ( byte buffer, int size ) : Encoding

Checks if a buffer contains text that looks like utf16 by scanning for newline chars that would be present even in non-english text.

CheckUtf8 ( byte buffer, int size ) : Encoding

Checks if a buffer contains valid utf8.

DoesContainNulls ( byte buffer, int size ) : bool

Checks if a buffer contains any nulls. Used to check for binary vs text data.

Method Details

CheckBom() public method

Checks for a BOM sequence in a byte buffer.
public CheckBom ( byte buffer, int size ) : Encoding
buffer byte
size int
return Encoding

DetectEncoding() public method

Automatically detects the Encoding type of a given byte buffer.
public DetectEncoding ( byte buffer, int size ) : Encoding
buffer byte The byte buffer.
size int The size of the byte buffer.
return Encoding

GetBomLengthFromEncodingMode() public static method

Gets the BOM length for a given Encoding mode.
public static GetBomLengthFromEncodingMode ( Encoding encoding ) : int
encoding Encoding
return int