1

ZIP

zip -r --symlinks ../a.zip a a.txt 
  adding: a/šáčžřŠÁČÝŘŽÚ§/ (stored 0%)

Filename is stored properly in unicode.

LIST

unzip -l ../a.zip 
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  03-11-2021 14:40   a/s??a??c??z??r??S??A??C??Y??R??Z??U??§/

unzip list prints crapy chars.

The filenames are stored in zip correctly in unicode because the unzip restores them properly but I need to show the zip listing in correct unicode chars.

How do I print the listing in correct unicode? Has this anything to do with shell settings?

locale

LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I'm on MacOS system.

Tried all this, still the same result :-(

LC_ALL=UTF-8 zip...
LC_ALL=UTF-8 unzip...

LANG =UTF-8 zip...
LANG =UTF-8 unzip...

I've also tried all lang variants:

LANG=cs_CZ.UTF-8 unzip -l ../unzip.zip
LANG=en_US.UTF-8 unzip -l ../unzip.zip

All these lang variants are listed in locale -a and still produce invalid output :-(

bsdtar works fine without any locale settings.

bsdtar tvvf ../unzip.zip 
drwxr-xr-x  0 501    20          0 Mar 11 14:40 a/šáčžřŠÁČÝŘŽÚ§/
Archive Format: ZIP 1.0 (uncompressed),  Compression: none
3
0

It should work with

LANG=en_US.UTF-8 unzip -l a.zip

UTF-8 is not a valid value for LANG. To list available locales, try

locale -a

In case en_US.UTF-8 is not listed there, try one of the ones that are listed and end in UTF-8.

I tried this on a Ubuntu system but I believe this should apply to Mac OS as well.
I also verified that I get similarly problematic outputs as you when setting LANG="" as is currently set in your locale or LANG=UTF-8 as was suggested in the comments.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.