
想用批處理調(diào)用外部nodejs命令處理文本怎么解決下面方式調(diào)用node處理文件時候亂碼,怎么解決?
nclick="copycode($('code0'));">復(fù)制代碼
- @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);
- }

