How to find out the character set of a text file

Solution 1:

If you are using Windows try downloading Notepad++. It should recognize the encoding and offers several conversions including UTF-8.

Solution 2:

  • for linux, use file -i filename
  • for mac, use file -I filename

For instance,

$ file -i readme.txt 
readme.txt: text/plain; charset=iso-8859-1

BTW, for converting, use iconv, for instance,

iconv -f ISO-8859-1 -t UTF-8 filename