RedHat Linux 6.0 中文编码问题描述:FTP传一个中文压缩文件上服务器,若是ZIP文件中存在中文文件名,则解压出来会乱码。
解决办法:把以下脚本保存成unzipgbk.py,存放于/bin目录下,解压时候用类似以下的命令:unzipgbk 中文名称.zip#!/usr/bin/env python
import os
import sys
import zipfile
print "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.close
file.close()
[root@localhost bin]# more unzipgbk
if [ $# -ne 1 ] ; then
echo "Usage testabc filename"
exit 0;
fi;echo "argument is " $1
python /bin/unzipgbk.py $1
更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10openSUSE 上面运行Eclipse崩溃的问题Fedora x86_64 Eclipse编写java程序时在进行智能填充时出现崩溃问题的解决相关资讯 RedHat Linux教程
- 轻松解决Linux系统下安装软件包问 (10/28/2012 08:15:17)
- RedHat5.5和Solaris10 Linux设置共 (09/17/2012 09:44:35)
- RedHat Linux下iptables防火墙设置 (08/03/2012 09:03:12)
| - Red Hat Linux 9通过NAT方式配置网 (10/21/2012 08:36:03)
- Redhat 与Windows下的远程桌面 (09/14/2012 18:57:19)
- VMware下RedHat9鼠标选用USB后不能 (06/24/2012 11:58:15)
|
本文评论 查看全部评论 (0)