Linux system unzip decompression Chinese name garbled solution

  

Solution one, use pyton to handle

1.vi uzip file

2. Copy the content (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[ ,null,null,3],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()

3.chmod +x uzip

4../uzip xxxx.zip

Method 2, uncompress by unzip line command , specify the character set

unzip -O CP936 xxx.zip (with GBK, GB18030 is also available)

Interestingly, there is no description of this option in the unzip manual, unzip – help This parameter has a simple description of one line.

Method 3, in the environment variable, specify the unzip parameter, always display and decompress the file in the specified character set

Add 2 lines in /etc/environment

UNZIP =”-O CP936″

ZIPINFO=”-O CP936″

Method 4, use the java jar command to extract the zip package JAR decompression

jar xvf file. Name
zh-CN"],null,[0.68563503],zh-CN"]]]

Copyright © Windows knowledge All Rights Reserved