Monday, November 24, 2008

Batch Convert UTF-8

For i18n, multi-language web content, there is always confusion about text encoding standard, namely English(ISO-8859-1), Chinese(simplied chinese in GB2312 or traditional chinese in BIG5 format) and UTF-8.

At this point of time, I couldn't find a convinient tool to conviniently convert other encoding standards into UTF-8.

The following Unix command can do the job - iconv

To batch convert all files under the current directory, here's the combination:
find . -name "*.php" -exec iconv -f ISO-8859-1 -t utf-8 {} -o {}.new \;

Note the " \;" (that's _space_\; ... It's essential. )