Question Fetch the Encoding type of a file

jebinjc

New member
Joined
Sep 18, 2012
Messages
1
Programming Experience
3-5
Hi,
Was trying to find the encoding type of a file like unicode, utf8, utf8 with 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?
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
857
Location
Norway
Programming Experience
10+
There is no BOM for ANSI, also for any Unicode encoding it is optional. ANSI may also mean any old code page, but could in a system mean the default code page. While in some cases BOM can be used to detect encoding, its primary function is strictly for detecting byte order (endianness) when transferring text data between different computer systems. There are long discussions to be found about detecting text encoding if you search the web.
 
Top Bottom