TryDetectEncoding Method
Definition
TryDetectEncoding(byte[], out Encoding)
Tries to detect the encoding represented by the byte order mark in the specified byte array.
public static bool TryDetectEncoding(byte[] input, out Encoding result)
Parameters
inputbyte[]The byte array to inspect.
resultEncodingWhen this method returns, contains the detected Encoding if detection succeeds; otherwise, null.
Returns
TryDetectEncoding(Stream, out Encoding)
Tries to detect the encoding represented by the byte order mark in the specified stream.
public static bool TryDetectEncoding(Stream value, out Encoding result)
Parameters
valueStreamThe stream to inspect.
resultEncodingWhen this method returns, contains the detected Encoding if detection succeeds; otherwise, null.
Returns
Remarks
This method reads up to the first four bytes of value and restores the original stream position
before returning. The stream must support seeking.