下面方式调用node处理文件时候乱码,怎么解决?- @if(0)==(0) echo off
- REM.保存为ANSI编码
- dir /b/a-d/oN "*.txt" | cscript -nologo -e:jscript "%~0"
- pause & goto :EOF
- @end
- fso = new ActiveXObject("Scripting.FileSystemObject");
- var shell = new ActiveXObject("WScript.Shell");
- while (!WSH.StdIn.AtEndOfStream) {
- var file = WSH.StdIn.ReadLine();
- var command = 'cmd /c node -e "console.log(fs.readFileSync(\''+file+'\', \'UTF-8\'))"';
- //var command = 'cmd /c node -e "require(\'fs\').readFile(\''+file+'\', \'UTF-8\', function(err, data){console.log(data)})"';
- var execObject = shell.Exec(command);
- var output = execObject.StdOut.ReadAll();
- WScript.Echo(output);
- }
复制代码
|