RedHat Linux 6.0 中文编码问题

RedHat Linux 6.0 中文编码问题描述:

FTP传一个中文压缩文件上服务器,若是ZIP文件中存在中文文件名,则解压出来会乱码。

解决办法:

把以下脚本保存成unzipgbk.py,存放于/bin目录下,,解压时候用类似以下的命令:unzipgbk 中文名称.zip

#!/usr/bin/env pythonimport osimport sysimport zipfileprint “Processing File ” + sys.argv[1]file=zipfile.ZipFile(sys.argv[1],”r”);for name in file.namelist(): utf8name=name.decode(‘gbk’) print “Extracting ” + utf8name pathname = os.path.dirname(utf8name) if not os.path.exists(pathname) and pathname!= “”: os.makedirs(pathname) data = file.read(name) if not os.path.exists(utf8name): fo = open(utf8name, “w”) fo.write(data) fo.closefile.close() [root@localhost bin]# more unzipgbkif [ $# -ne 1 ] ; then echo “Usage testabc filename” exit 0;fi;

echo “argument is ” $1python /bin/unzipgbk.py $1

更多RedHat相关信息见RedHat 专题页面 ?tid=10

人生就像是一场旅行,遇到的既有感人的,

RedHat Linux 6.0 中文编码问题

相关文章:

你感兴趣的文章:

标签云: