How to find out the character set of a text file

7

2

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

Posted 2010-03-24T19:58:14.190

Reputation: 341

Answers

9

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

Beaner

Posted 2010-03-24T19:58:14.190

Reputation: 3 193

if you need to convert your file: http://www.rishida.net/tools/conversion/

– Adrien Be – 2014-06-23T14:44:57.427

Nice tool, thank you!! (my score is 11 so I can't boost your). – ragnarius – 2010-03-24T20:31:45.320

7

  • 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

SparkAndShine

Posted 2010-03-24T19:58:14.190

Reputation: 171

Thanks, but it does not convert – ragnarius – 2015-06-01T21:15:50.787

1In speaking of converting, use the command iconv. For instance, iconv -f ISO-8859-1 -t UTF-8 filename – SparkAndShine – 2015-06-02T07:03:59.573

With file command, why did both two files encoded with big5 and gb2312 present iso-8859-1? – niaomingjian – 2018-02-11T06:24:07.203