RedHat Chinese encoding in Linux 6.0

Source: Internet
Author: User

RedHat Chinese encoding in Linux 6.0

RedHat Linux 6.0 Chinese encoding Problem description:

FTP transfers a Chinese compressed file to the server. If the ZIP file contains a Chinese file name, unzipping will cause garbled characters.

Solution:

Save the following script as unzipgbk. py and store it in the/bin directory. Run the following command: unzipgbk Chinese name. 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

For more information about RedHat, see RedHat topic page http://www.bkjia.com/topicnews.aspx? Tid = 10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.