File names with Japanese characters turn into garbage when they are written to a zip file using java.util.zip. *

I have a directory with a name that contains Japanese characters, and I need to use zip utils in java.util.zip to write it to a zip file. Writing a zip file is successful, but when I open the resulting zip file using the built-in Windows or 7-Zip compressed file utility, the directory with Japanese characters in the name appears as a bunch of garbage characters. I have a Japanese / East Asian language pack installed on my system - I can create directories with Japanese names, so this is not a problem.

Interestingly, if I write a separate script to read the resulting zip file using java.util.zip, the directory name is correct, and I can extract the contents of the zip into the corresponding directories with Japanese characters. But I can’t do this using the commercial zip tools I tried, which our clients will undoubtedly do.

Any ideas on what causes this problem, and how can I get around it?

I know about this error , but I still need a workaround for this case.

+3
source share
3 answers

java.util.zip , , ( , ). Chilkat Java Zip library, , , .

+1

TrueZIP , :

API J2SE UTF-8 ( Unicode) CP437 (a.k.a. IBM437, IBM- ), - PKZIP PKWARE. ZIP , , , "Täscht.txt" ZIP , () .

[ ]

TrueZIP /.

+3

Miracles really happen, and Sun / Oracle really fixed the long-lived bug / rfe:

Now you can [configure encodings of file names when creating] [1] zip file / stream ( Java 7 required ).

[1]: http://download.java.net/jdk7/docs/api/java/util/zip/ZipOutputStream.html#ZipOutputStream(java.io.OutputStream , java.nio.charset.Charset)

+2
source

Source: https://habr.com/ru/post/1726846/


All Articles