iconv: making character encoding just a tiny bit less hellish

February 03, 2009 at 03:17 PM | Uncategorized | View Comments

Ug, I hate character encodings.

But there is a tool that can help to make your life slightly (slightly) less hellish: iconv. It will convert a bag of bytes from any character encoding TO any character encoding:

$ iconv -f windows-1252 -t utf-8 < input > output

Where the -f flag is "from encoding" and the -t flag is the "to" encoding. latin1 is also a good candidate for the "from" encoding.

Just don't go and re-encode a database dump, then leave it running for a few days, THEN realize you've gotten it wrong...