gbk转utf-8

1、文件转码:使用脚本
 
gbk转u8的脚本文件:
#!/bin/bash

FILE_SUFFIX="java xml html vm js"
# FILE_SUFFIX="vm"
file_names=""
for x in $FILE_SUFFIX
do
	file_names=`find . -name "*.$x" | xargs file -I | grep -v utf-8 | awk -F " |:" '{print $1}'`
	for file_name in $file_names
	do
		# echo $file_name
		iconv -f cp936 -t UTF-8 $file_name >$file_name".new" &&
	    mv -f "$file_name.new" "$file_name"
	done
	echo "$x ok"

done


find . -name "*.xml" | xargs sed -i "" "//s/GBK/UTF-8/g"
find . -name "pom.xml" | xargs sed -i "" "//s/GB2312/UTF-8/g"
find . -name "pom.xml" | xargs sed -i "" "/project.build.sourceEncoding/s/GBK/UTF-8/g"
find . -name "pom.xml" | xargs sed -i "" "/project.reporting.outputEncoding/s/GBK/UTF-8/g"
find . -name "pom.xml" | xargs sed -i "" "s/pop-vender-common-pageframe/pop-vender-common-pageframe-utf8/g"

echo "pom.xml is ok!"

find . -name "*.properties" | xargs sed -i "" "/input.encoding/s/GBK/UTF-8/g"
find . -name "*.properties" | xargs sed -i "" "/output.encoding/s/GBK/UTF-8/g"

echo "velocity properties is OK!"

find . -name "strut*.xml" | xargs sed -i "" '/struts.i18n.encoding/s/GBK/UTF-8/g'

echo "struts xml is ok!"

find . -name "*.vm" | xargs sed -i "" "s/\/common\/js\/jdmsg\/jd-msg.js/\/common\/js\/jdmsg\/jd-msg-utf8.js/g"
find . -name "*.vm" | xargs sed -i "" "/\/ui.datepicker.js/s/
                    
                    

你可能感兴趣的:(gbk转utf-8)