One - One Code All

Blog Content

Mac下GBK与UTF8编码文件的转换iconv

Linux-Mac   2018-02-24 16:24:37

shell命令:iconv

iconv --list # 显示可识别的编码名称
iconv --list >./infomation.log # 显示可识别的编码名称,将信息存入infomation.log文件中
iconv -f GB2312 -t UTF-8 a.html > b.html # 转换GB2312编码的文件a.html为UTF-8编码,存入b.html
iconv -f GB2312 -t BIG5 a.html > b.html # 转换GB2312编码的文件a.html为BIG5编码,存入b.html
进入正题,我们先cd进入保存所有文件的文件夹,然后执行下列命令:

find *.py -exec sh -c "iconv -f GB18030 -t UTF8 {} > {}.py" \;  
上面命令中的GB18030,如果你转换前的编码为GB2312,将 GB18030 代替为 GB2312 即可。


上一篇:java 字符串与整型相互转换
下一篇:git配置并提交代码到github

The minute you think of giving up, think of the reason why you held on so long.