jueves, 26 de enero de 2017

Visualise and modify the character encoding of a file

To see the character encoding of a file use the command "file" with the option -i or --mime. This shows the mime (Multipurpose Internet Mail Extensions) type strings. In the following example, we see the charset of an index.html file

$ file -i ./index.html
./index.html: text/html; charset=iso-8859-1

We can use the command "iconv" to convert the encoding of a given file from one encoding to another. In the next example from iso-8859-1 to utf-8