Hi,
I was trying to find the encoding type of a file like unicode, utf8, utf8 without BOM, ANSI etc. I was able to find all the encoding type but ANSI(Encoding.Default/Windows- 1252). I am not able to differentiate ANSI and UTF8. Tried different custom class like (Ude, TextFileEncodingDetector etc) which guesses it but not exactly right. Is there any way to do it?
Fetch the Encoding type of a file in C#
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Sep 18, 2012, 7:30 AM EDT
However, one thing you could do is to look for bytes with values between 128 and 159 (0x80 and 0x9F hex). If there are any of these, then there's a high probability that it's a Windows-1252 file because these characters represent (rarely used) non-printing control characters in Unicode and therefore UTF-8.