I use spawn for JScript (from windows) My problem with decode text
???? ??? T-SQL Microsoft SQL Server 2012
???? ??? - russian text.
var worker,path = require('path'), spawn = require('child_process').spawn, cscript = path.join(process.env.SystemRoot, 'system32', 'cscript.exe')
function startCscript() {
worker = spawn( cscript, [ '/nologo', 'testwsh.js' ] );
worker.stdout.setEncoding('utf8');
worker.stdout.on( 'data', onData );
}
function onData (data) {
console.log(data.toString());
}
startCscript();
How do I get Russian letters? Thanks all )
Can you try to set the worker encoding as ucs2 or utf16le.
Change this
worker.stdout.setEncoding('utf8');
to this
worker.stdout.setEncoding('ucs2');
Tell if it solves the issue.
look at issue 2190 and issue 2196:
Node.js does always expect UTF-8 output from a child process, but Windows with Russian locale defaults to CP866
you need to execute chcp 65001 to change current console code page.
My solution: use iconv-lite, to get the Russian text in the console.