从 windows 拷贝到 linux 时,中文出现乱码问题,这里给出一个转化脚本,利用这个脚本对出现乱码的文件进行处理(实际上是将文件字符编码方式从 windows 的 gb18030 转 linux 下的 utf-8)
可以直接使用命令iconv -f gb18030 -t utf-8 file1 > file2
#!/bin/sh __usage() { echo "usage: gb2utf [gb_file] [utf_file]" echo " gb2utf [gb_file]" } if [ -z $1 ] then __usage exit 1 fi if [ -z $2 ] then if [ -z $1 ] then __usage else [ -f $1 ] || { echo "$1 is not a file" exit 1 } touch .$1 iconv -f gb18030 -t utf-8 $1 > .$1 cat .$1 > $1 rm -f .$1 exit 0 fi else if [ -f $1 ] then iconv -f gb18030 -t utf-8 $1 > $2 else echo "$1 is not a file" exit 1 fi fi