bnoordhuis / node-iconv

node.js iconv bindings - text recoding for fun and profit!
Other
800 stars 123 forks source link

convert char '裏' from utf8 to big5 will throw exception #103

Closed YuhangGe closed 9 years ago

YuhangGe commented 9 years ago
var Iconv = require('iconv').Iconv;
var iconv = new Iconv('utf8', 'big5');
iconv.convert('裏')

Error: Illegal character sequence.

bnoordhuis commented 9 years ago

I don't think that's a bug. The character isn't representable in plain Big5 but Big5-2003 or HKSCS should work:

> Iconv('utf8', 'big5').convert('裏')
Error: Illegal character sequence.
# elided

> Iconv('utf8', 'big5-2003').convert('裏')
<Buffer f9 d8>

> Iconv('utf8', 'big5-hkscs').convert('裏')
<Buffer f9 d8>
rambo-panda commented 9 years ago

try

var inconv_gbk = new Iconv('UTF-8', 'GBK//TRANSLIT//IGNORE').convert;