How to convert character encoding from CP932 to UTF-8 in nodejs javascript, using the nodejs-iconv module (or other solution)

和自甴很熟 提交于 2019-11-29 00:15:35

I got same trouble today :)
It depends libiconv. You need libiconv-1.13-ja-1.patch.
Please check followings.

or you can avoid problem using iconv-jp try

npm install iconv-jp

I had same problem, but with CP1250. I was looking for problem everywhere and everything was OK, except call of request – I had to add encoding: 'binary'.

request = require('request')
Iconv  = require('iconv').Iconv

request({uri: url, encoding: 'binary'}, function(err, response, body) {
    body = new Buffer(body, 'binary')
    iconv = new Iconv('CP1250', 'UTF8')
    body = iconv.convert(body).toString()
    // ...
})

https://github.com/bnoordhuis/node-iconv/issues/19

I tried /Users/Me/node_modules/iconv/test.js node test.js. It return error.

On Mac OS X Lion, this problem seems depend on gcc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!