C# Class MarkDownEditor.SimpleHelpers.FileEncoding

ファイルを表示 Open project: chenguanzhou/MarkDownEditor Class Usage Examples

Public Methods

Method Description
CheckForTextualData ( byte rawData ) : bool

Detects if contains textual data.

CheckForTextualData ( byte rawData, int start, int count ) : bool

Detects if contains textual data.

Complete ( ) : Encoding

Finalize detection phase and gets detected encoding name.

Detect ( Stream inputData ) : string

Detects the encoding of textual data of the specified input data. Only the stream first 20Mb will be analysed.

Detect ( Stream inputData, int maxSize, int bufferSize = 16*1024 ) : string

Detects the encoding of textual data of the specified input data.

Detect ( byte inputData, int start, int count ) : string

Detects the encoding of textual data of the specified input data.

DetectFileEncoding ( Stream inputStream, Encoding defaultIfNotDetected = null ) : Encoding

Tries to detect the file encoding.

DetectFileEncoding ( byte inputData, int start, int count, Encoding defaultIfNotDetected = null ) : Encoding

Tries to detect the file encoding.

DetectFileEncoding ( string inputFilename, Encoding defaultIfNotDetected = null ) : Encoding

Tries to detect the file encoding.

Reset ( ) : void

Resets this instance.

TryLoadFile ( string filename, string defaultValue = "" ) : string

Tries to load file content with the correct encoding.

Private Methods

Method Description
CheckForByteOrderMark ( byte rawData, int start ) : bool

Detects if data has bytes order mark to indicate its encoding for textual data.

GetCurrentEncoding ( ) : string
IncrementFrequency ( string charset ) : void

Method Details

CheckForTextualData() public static method

Detects if contains textual data.
public static CheckForTextualData ( byte rawData ) : bool
rawData byte The raw data.
return bool

CheckForTextualData() public static method

Detects if contains textual data.
public static CheckForTextualData ( byte rawData, int start, int count ) : bool
rawData byte The raw data.
start int The start.
count int The count.
return bool

Complete() public method

Finalize detection phase and gets detected encoding name.
public Complete ( ) : Encoding
return System.Text.Encoding

Detect() public method

Detects the encoding of textual data of the specified input data. Only the stream first 20Mb will be analysed.
public Detect ( Stream inputData ) : string
inputData Stream The input data.
return string

Detect() public method

Detects the encoding of textual data of the specified input data.
bufferSize parameter cannot be 0 or less.
public Detect ( Stream inputData, int maxSize, int bufferSize = 16*1024 ) : string
inputData Stream The input data.
maxSize int Size in byte of analysed data, if you want to analysed only a sample. Use 0 to read all stream data.
bufferSize int Size of the buffer for the stream read.
return string

Detect() public method

Detects the encoding of textual data of the specified input data.
public Detect ( byte inputData, int start, int count ) : string
inputData byte The input data.
start int The start.
count int The count.
return string

DetectFileEncoding() public static method

Tries to detect the file encoding.
public static DetectFileEncoding ( Stream inputStream, Encoding defaultIfNotDetected = null ) : Encoding
inputStream Stream The input stream.
defaultIfNotDetected System.Text.Encoding The default encoding if none was detected.
return System.Text.Encoding

DetectFileEncoding() public static method

Tries to detect the file encoding.
public static DetectFileEncoding ( byte inputData, int start, int count, Encoding defaultIfNotDetected = null ) : Encoding
inputData byte The input data.
start int The start.
count int The count.
defaultIfNotDetected System.Text.Encoding The default encoding if none was detected.
return System.Text.Encoding

DetectFileEncoding() public static method

Tries to detect the file encoding.
public static DetectFileEncoding ( string inputFilename, Encoding defaultIfNotDetected = null ) : Encoding
inputFilename string The input filename.
defaultIfNotDetected System.Text.Encoding The default encoding if none was detected.
return System.Text.Encoding

Reset() public method

Resets this instance.
public Reset ( ) : void
return void

TryLoadFile() public static method

Tries to load file content with the correct encoding.
public static TryLoadFile ( string filename, string defaultValue = "" ) : string
filename string The filename.
defaultValue string The default value if unable to load file content.
return string