Kéménybe, korommal #2

The UnZip package assumes that filenames stored in the ZIP archives created on non-Unix systems are encoded in CP850, and that they should be converted to ISO-8859-1 when writing files onto the filesystem. Such assumptions are not always valid. In fact, inside the ZIP archive, filenames are encoded in the DOS codepage that is in use in the relevant country, and the filenames on disk should be in the locale encoding. In MS Windows, the OemToChar() C function (from User32.DLL) does the correct conversion (which is indeed the conversion from CP850 to a superset of ISO-8859-1 if MS Windows is set up to use the US English language), but there is no equivalent in Linux.

When using unzip to unpack a ZIP archive containing non-ASCII filenames, the filenames are damaged because unzip uses improper conversion when any of its encoding assumptions are incorrect.

Ezért az első lépés windows7-en készített magyar ékezetes fájlnevű zip esetén:


convmv -f iso-8859-1 -t cp850 -r --nosmart --notest /path/to/unzipped/files

Utána:


convmv -f cp852 -t utf8 -r --nosmart --notest /path/to/unzipped/files

-----


$ aptitude show unzip
Package: unzip                           
State: installed
Automatically installed: yes
Multi-Arch: foreign
Version: 6.0-8
Priority: optional
Section: utils
Maintainer: Santiago Vila <sanvila@debian.org>
Architecture: amd64
Uncompressed Size: 386 k
Depends: libbz2-1.0, libc6 (>= 2.4)
Suggests: zip
Conflicts: unzip-crypt (< 5.41), unzip-crypt (< 5.41), unzip
Replaces: unzip-crypt (< 5.41), unzip-crypt (< 5.41)
Provides: unzip
Provided by: unzip
Description: De-archiver for .zip files
 InfoZIP's unzip program. With the exception of multi-volume archives (ie, .ZIP files that are split across several disks using PKZIP's /& option), this can handle any file
 produced either by PKZIP, or the corresponding InfoZIP zip program. 
 
 This version supports encryption.
Homepage: http://www.info-zip.org/UnZip.html

Hozzászólások

Én ugyan a magyarázat ellenére se értem, hogy ez a két konverzió hogyan segít, de azért megjegyzem.

Beégetett kódolással tárolja a fájl neveket a ZIP, ez a probléma. Bizonyos orosz verziókban már patch-elik régóta egyébként. A fenti convmv csak a már kicsomagolt fájlok neveinek karaktereit alakítja át másik kódolásba.

Persze sajnos ettől még nem az eredeti problémát oldja meg, és továbbra is függeni fog a művelet attól, hogy milyen rendszeren készült a zip milyen karakter kódolással, és hogy milyen karakter kódolású rendszeren akarjuk kicsomagolni.

a hiba annál van elásva, aki ékezetet használ fájlnévben.