Decompress the Winzip package containing the Chinese file name

Source: Internet
Author: User
Article Title: Decompress the Winzip package containing the Chinese file name. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   I. Problems:
One day someone sent me a. ZIP file. I unzip it, but found that the file name of the Chinese name is wrong.
  
   2. search for answers online:
Some netizens told me that winzip used some OEM method to modify the file name (which proved to be wrong later). It only needed another powerful zip and disabled the OEM Method for compression. But I don't think we should allow someone else to use a certain piece of software for Unzip.
  
   Iii. temporary solution: * The solution provided in this article is a temporary solution *
1. What is the problem?
---------------------------
Experiment 1: In linux, use zipzip to compress two Chinese name files with the same name as 1.zip,
Result 1: The file name is correct when you use Winzip to open Windows 98.
  
Tutorial 2: Use winzipzip to file two Chinese files with the same name as 2.zip in Windows98,
Result 2: in Linux, the Chinese name opened with Unzip is completely incorrect, but the length is the same.
  
Experiment 3: compare two compressed files (1.zip,2.zip) with a two-step producer ),
Result 3: The binary encoding of the file names in the two compressed files is the same.
  
Experiment 4: Unzip compares the information of two compressed files
Result 4: Except for different file names, the type is different. One is Unix and the other is fat.
  
Conclusion:
The method for saving the winzip file name is exactly the same as that for Unzip,
In Unzip, the file name in the compressed file of the type "fat" is explained separately.
  
2. Solution
***************************************
* Modify Unzip so that it does not explain the file name separately. *
***************************************
Find it... and finally find it (I learned emacs and etags)
========================================================== ==============================================
The unzpriv. h file in the Unzip-5.42 source file package is about 2396th rows up and down.
========================================================== ==============================================
/* Convert filename (and file comment string) into "internal" charset.
* This macro assumes that Zip entry filenames are coded in OEM (ibm dos)
* Codepage when made on
*-> DOS (this includes des 16-bit Windows 3.1) (FS_FAT _)
*-> OS/2 (FS_HPFS _)
*-> Win95/WinNT with Nico Mak's WinZip (FS_NTFS _ & hostver = "5.0 ")
* EXCEPTIONS:
* PKZIP for Windows 2.5 and 2.6 flag their entries as "FS_FAT _", but
* Filename stored in the local header is coded in Windows ANSI (ISO 8859-1 ).
* Likewise, PKZIP for UNIX 2.51 flags its entries as "FS_FAT _", but
* Filenames stored in BOTH the local and the central header are coded
* In the local system's codepage (usually ANSI codings like ISO 8859-1 ).
*
* All other ports are assumed to code zip entry filenames in ISO 8859-1.
*/
# Ifndef Ext_ASCII_TO_Native
# Define Ext_ASCII_TO_Native (string, hostnum, hostver, isuxatt, islochdr )\
If (hostnum) = FS_FAT _&&\
! (Islochdr) | (isuxatt ))&&\
(Hostver) >=25 & (hostver) <= 26) | \
(Hostnum) = FS_HPFS _ | \
(Hostnum) = FS_NTFS _ & (hostver) = 50 )){\
_ OEM_INTERN (string ));\
} Else {\
_ ISO_INTERN (string ));\
}
# Endif
========================================================== ============================================
**************************************** ***
* Temporary correction method: All use function _ ISO_INTERN ()*
**************************************** ***
Modify as follows:
========================================================== ============================================
# Ifndef Ext_ASCII_TO_Native
# Define Ext_ASCII_TO_Native (string, hostnum, hostver, isuxatt, islochdr )\
/* If (hostnum) = FS_FAT _&&\
*! (Islochdr) | (isuxatt ))&&\
* (Hostver)> = 25 & (hostver) <= 26) | \
* (Hostnum) = FS_HPFS _ | \
* (Hostnum) = FS_NTFS _ & (hostver) = 50 )){\
* _ OEM_INTERN (string ));\
*} Else {\*/
_ ISO_INTERN (string ));\
/*}*/
# Endif
========================================================== ==============================================
Compiled successfully. Try it. The Chinese name of winzip compression is recognized correctly !!!
========================================================== ==============================================
  
   Iv. Limitations and temporary nature of the method:
**************************************** ***********************
* The disadvantage of the method is obvious. The file names that have been specially processed cannot be correctly supported !!! *
* Please advise on better methods !!! *
**************************************** ***********************
Related Article

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.