简体   繁体   中英

Java, Archives, Linux & Cyrillic

I try to write an archiver in java, that creates TAR or ZIP archives, with correctly cyrillic file names, then it opened in linux. In windows I use org.apache.tools.zip, from ant:

ZipOutputStream.setEncoding("cp866"); 

to get it, but file roller (archive manager) in linux don't understand it. In org.apache.tools.tar method setEncoding() isn't exists. Also I try to use some other encoding, that supports Cyrillic, such a cp1251, utf-8, koi-8r but it gaves no result.

Your file may be creating the files correctly and the problem lies on file-roller. It's known that it can't detect filename's encoding. See here and here .

Attempt to use unzip (filenames will probably be garbled) or p7zip directly from the shell (there is also a java version - j7zip).

7zip works for me, with utf8 encoding of Cyrillic characters. File roller, Ark, and all others that in fact execute unzip will corrupt the filenames in my system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM