本帖最后由 CrLf 于 2014-7-27 20:01 编辑
GB2312 编码是不支持韩文的,强行从 unicode 转为 扩展ASCII码 极易会丢失字符
949 代码页不知道为什么又没法用,1201 无效果,65001 在 xp 下又有问题
---------------------------------------------------------------------------------
powershell 默认输出就是 unicode:- ((select-string "DIAMONDS=" a.inf).line -split '"')[1]>b.inf
复制代码 perl 也可实现,非系统自带:- use Encode;
-
- open(IN,"<:encoding(utf-16)","a.inf");
- open(OUT,">b.inf");
- binmode(OUT, ":encoding(utf-16)");
- while(<IN>){
- print OUT ((split /"/)[1]) if /^DIAMONDS=/;
- }
复制代码 再来个 python...- import codecs
- import re
-
- text =open('a.inf', encoding='utf-16').read()
- text=re.sub(r'[\s\S]*DIAMONDS="(.*)"[\s\S]*','\g<1>',text)
- open('b.inf', 'w', encoding='utf-16').write(text)
复制代码
|