DetectEncodingOrDefault Method
Definition
DetectEncodingOrDefault(byte[], Encoding)
Detects the encoding of the specified byte array, or returns a fallback encoding if detection fails.
public static Encoding DetectEncodingOrDefault(byte[] input, Encoding fallbackEncoding)
Parameters
inputbyte[]The byte array to inspect.
fallbackEncodingEncodingThe encoding to return when detection fails.
Returns
- Encoding
The detected encoding of
input, orfallbackEncodingif detection fails. IffallbackEncodingis null, DefaultEncoding is returned.
DetectEncodingOrDefault(Stream, Encoding)
Detects the encoding of the specified stream, or returns a fallback encoding if detection fails.
public static Encoding DetectEncodingOrDefault(Stream value, Encoding fallbackEncoding)
Parameters
valueStreamThe stream to inspect.
fallbackEncodingEncodingThe encoding to return when detection fails.
Returns
- Encoding
The detected encoding of
value, orfallbackEncodingif detection fails.