How to find out and change file encoding in Ubuntu

First, you can find a file’s encoding like this:

$ file oldfilename.txt 
oldfilename.txt: ISO-8859 English text

Then, if you want to convert the file oldfilename.txt from ISO-8859 to UTF-8 and call the new UTF-8 file newfilename.txt you do like this:

$ iconv -f ISO-8859-1 -t UTF-8 -o newfilename.txt oldfilename.txt

Note that the file command says ISO-8859 and that you have to use ISO-8859-1 in the iconv command.
For a long list of available iconv encodings, use

$ iconv -l

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>