- @if (0)==(0) echo off
- dir /b a.txt | cscript.exe -nologo -e:jscript %0
- pause & exit
- @end
- while (!WSH.StdIn.AtEndOfStream) {
- var file = WSH.StdIn.ReadLine();
- adoLoadText(file, "UTF-8", "GBK");
- }
-
- function adoLoadText(file, enc1, enc2) {
- var stream, text;
- stream = new ActiveXObject("ADODB.Stream");
- stream.type = 2;
- stream.charset = "437";
- stream.open();
- stream.loadFromFile(file);
- var bom = escape(stream.ReadText(2));
- if (bom == "%u2229%u2557") {
- stream.Position = 0;
- stream.charset = enc1;
- text = stream.readText(-1);
- stream.Position = 0;
- stream.charset = enc2;
- stream.WriteText(text);
- stream.SetEOS();
- stream.SaveToFile(file, 2);
- }
- stream.close();
- }
复制代码
|