中文名在linux中必須是亂碼的哦這個沒話說了,當然如果有配置好的估計是可以解決,下面小編整理了一些解決unzip解壓后中文名亂碼問題.
解決辦法一:利用pyton來處理
1.vi uzip文件
2.復制一下內容(Python)
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # uzip.py
- 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) //Vevb.com
- data = file.read(name)
- if not os.path.exists(utf8name):
- fo = open(utf8name, "w")
- fo.write(data)
- fo.close
- file.close()
- 3.chmod +x uzip
- 4../uzip xxxx.zip
方法2,通過unzip行命令解壓,指定字符集:
unzip -O CP936 xxx.zip(用GBK,GB18030也可以)
有趣的是unzip的manual中并無這個選項的說明,unzip –help對這個參數有一行簡單的說明.
方法3,在環境變量中,指定unzip參數,總是以指定的字符集顯示和解壓文件,/etc/environment中加入2行.
- UNZIP=”-O CP936″
- ZIPINFO=”-O CP936″
方法4,采用java的jar命令解壓zip包 JAR 解壓:jar xvf file.name
新聞熱點
疑難解答