-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
I write my code like
cmd.get(
'ipconfig',
function(err,data){
if(err) throw err;
console.log('the output of ipconfig is : ',data)
}
);
But the encoding of data is incorrect because the default encoding of exec is utf-8, and on some platform like a Chinese version of Windows, the output of command execution is cp936, then the final output is filled with incorrect characters.
However, I can do it with passing extra options to exec to make it work.
const iconv = require('iconv-lite');
const { exec } = require('child_process');
exec('ipconfig', { encoding: 'buffer' }, (error, stdout) => {
console.log('the output of ipconfig is : ',iconv.decode(stdout, 'cp936'));
});
So hope to add options to the underlying exec call.
Reactions are currently unavailable