nodejs调用系统命令,输出结果中文乱码问题
2017-06-11 本文已影响192人
2b75747cf703
var child_process = require('child_process');
var iconv = require('iconv-lite');
var encoding = 'cp936';
var binaryEncoding = 'binary';
child_process.exec('svn log', { encoding: binaryEncoding }, function(err, stdout, stderr){
console.log(iconv.decode(new Buffer(stdout, binaryEncoding), encoding), iconv.decode(new Buffer(stderr, binaryEncoding), encoding));
});