KevCaz's Website

Today I needed to check the character encoding of a file, I found this page that explains how to do this. Basically the command file will give you the info, for instance:

1
2
$ file example.md
example.md: ASCII text

options -i for --mime and -b for --brief will give:

1
2
$ file -bi example.md
text/plain; charset=us-ascii

I figured out that I needed to convert my file from one character encoding to another and so I used iconv. As mentioned in the link above, iconv -l will give you the list of character encodings iconv handles. In my case, I needed to convert the file from Latin1, aka iso8859-1 to UTF-8, so I used the following command line:

1
$ iconv -f iso8859-1 -t UTF8 changeencoding.md -o changeencoding_utf8.md