convert unicode chartset to utf8 in CLI

因為從 plurk 的 getPlurks 接回來的資料被轉成 unicode 了,所以使用以下方法轉回 utf8.
echo "\u6c49\u5b57" | \
sed 's/\\u\(..\)\(..\)/\\x\2\\x\1/g' | \
sed 's/.*/\"\\xff\\xfe&\"/g' | \
xargs printf | iconv -f utf-16 -t utf-8
ref: this & this

0 comments:

張貼留言