Determine Character Encoding Of A File

10 Dec 2013

How to determine the character encoding of a file?

# print out file type and encoding in human-readable format
$ file [filename]

# Or, output character encoding (in MIME-type string) only, 
# without filename being printed out
$ file -bi [filename]

That’s it!

Here is some reference for you to dig in a little further: including converting file to/from different encodings and setting up vim to save files in UTF-8 encoding automatically.