How to find out the character set of a text file

21,929

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
Share:
21,929

Related videos on Youtube

ragnarius
Author by

ragnarius

Updated on September 17, 2022

Comments

  • ragnarius
    ragnarius almost 2 years

    Is the a tool (mac or online) that can help me to find out the character set of a text file, and then convert it to utf-8 ?

  • ragnarius
    ragnarius over 14 years
    Nice tool, thank you!! (my score is 11 so I can't boost your).
  • Adrien Be
    Adrien Be about 10 years
    if you need to convert your file: rishida.net/tools/conversion
  • ragnarius
    ragnarius about 9 years
    Thanks, but it does not convert
  • SparkAndShine
    SparkAndShine about 9 years
    In speaking of converting, use the command iconv. For instance, iconv -f ISO-8859-1 -t UTF-8 filename
  • niaomingjian
    niaomingjian over 6 years
    With file command, why did both two files encoded with big5 and gb2312 present iso-8859-1?