有没有办法在节点或客户端网页中将文本从 CP852 转换为 UTF-8?
问问题
1494 次
1 回答
3
应该可以iconv
:
var iconv = require('iconv');
var cp852 = new iconv.Iconv('CP852', 'UTF-8');
// based on http://en.wikipedia.org/wiki/Code_page_852
// Ç (U+00C7), É (U+00C9), á (U+00E1), and ░ (U+2591)
var input = new Buffer([ 128, 144, 160, 176 ]);
console.log(cp852.convert(input));
或者您可以尝试iconv-lite
:
var iconv = require('iconv-lite');
var input = new Buffer([ 128, 144, 160, 176 ]);
console.log(iconv.decode(input, 'cp852'));
于 2012-09-21T17:16:27.993 回答