Character Encoding: Convert from UTF-8 to ISO-8859-1

The iconv program converts the encoding of characters in an input file from one coded character set to another. We have tested these commands on RHEL 5, but it should work on other Linux distributions just fine.

We have a test UTF-8 encoded file,

# file -bi TestspecialchrUTF.txt
text/plain; charset=utf-8

Let’s convert this file,

# iconv --from-code=utf-8 --to-code=iso-8859-1//TRANSLIT TestspecialchrUTF.txt -o TestISO8859.txt

Here the catch is TRANSLIT switch which is not present in the man page of iconv at the time of writing this blog post. Now let’s verify the character encoding of newly created file,

# file -bi TestISO8859.txt
text/plain; charset=iso-8859-1

Where the file is a Unix command to determine the file type.

Please provide any feedback using the comments below, and I invite you to check out following posts.