中文名在linux中必须是乱码的哦这个没话说了,当然如果有配置好的估计是可以解决,下面小编整理了一些解决unzip解压后中文名乱码问题。
解决办法一,利用pyton来处理
1.vi uzip文件
2.复制以下内容
[Python] 纯文本查看 复制代码 09 | print "Processing File " + sys.argv[ 1 ] |
11 | file = zipfile.ZipFile(sys.argv[ 1 ], "r" ); |
12 | for name in file .namelist(): |
13 | utf8name = name.decode( 'gbk' ) |
14 | print "Extracting " + utf8name |
15 | pathname = os.path.dirname(utf8name) |
16 | if not os.path.exists(pathname) and pathname! = "": |
18 | data = file .read(name) |
19 | if not os.path.exists(utf8name): |
20 | fo = open (utf8name, "w" ) |
3.chmod +x uzip
4../uzip xxxx.zip
解决办法二 ,通过unzip行命令解压,指定字符集
[Bash shell] 纯文本查看 复制代码 1 | unzip -O CP936 xxx.zip (用GBK, GB18030也可以) |
有趣的是unzip的manual中并无这个选项的说明,unzip –help对这个参数有一行简单的说明。
解决办法三,在环境变量中,指定unzip参数,总是以指定的字符集显示和解压文件
/etc/environment中加入2行
UNZIP=”-O CP936″
ZIPINFO=”-O CP936″
4. 方法4,采用java的jar命令解压zip包 JAR 解压
[Actionscript3] 纯文本查看 复制代码
|