Click or drag to resize

AsciiDocumentAnalysisTryGetEncodingOfStream Method

Tries to detect the encoding of a stream. The stream is read up to maxLines lines, and then the encoding is detected. If no encoding can be detected, null is returned.

Namespace: Altaxo.Serialization.Ascii
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3618.0 (4.8.3618.0)
Syntax
C#
public static (Encoding detectedEncoding, int numberOfBomBytes) TryGetEncodingOfStream(
	Stream stream,
	int maxLines = 1000
)

Parameters

stream  Stream
The stream to detect the encoding from.
maxLines  Int32  (Optional)
The maximum number of lines to read for detection.

Return Value

ValueTupleEncoding, Int32
The detected encoding and the number of BOM bytes, or null if no encoding can be detected.
Remarks
Note that the detected encoding could be UTF-8 and the number of BOM bytes nevertheless is 0. That is because here we have implemented a heuristic UTF-8 detection even if no BOM is present.
See Also