不知道你实际的文件有多大...保险一点用 fso 吧,慢一点,不过一行一行读不会超内存
把你要处理的文件 test_in.txt 存为 Unicode 编码,再把以下脚本存为 js 运行即可- var fso = new ActiveXObject('Scripting.FileSystemObject')
-
- var IN = fso.OpenTextFile('test_in.txt',1,true,true)
- var OUT = fso.OpenTextFile('test_out.txt',2,true,true)
-
- while(!IN.atEndOfStream){
- var line = IN.ReadLine()
-
- line = line.replace(/&#(\d{1,5});/g,function($0,$1){
- return String.fromCharCode($1)
- })
- OUT.WriteLine(line)
- }
-
- IN.Close()
- OUT.Close()
复制代码
|