Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create ZIP files with specific encoding

On my Linux server I have some files with accented names (test-éàïù.zip). When I add them to a new ZIP file using 7zip command-line tool, the charset/encoding information is not saved and when opened on a Windows computer, the archive does not correctly display filenames. I know that 7zip creates Zip V1.0 archives, not 2.0. Maybe the charset is limited to MSDos charset ? How could I specify an encoding using 7zip or another zip tool, in order to get portable archives?


1 Answers

This is a superuser question, BUT...

ZIP uses a default codepage of IBM437. There is the possibility to use UTF-8, but not all zip tools and libraries support that. Some zip tools will do arbitrary code pages, even though the zip spec allows only IBM437 or UTF-8. I think WinRar is one such tool.

DotNetZip does encoding. It will do UTF-8 or an arbitrary code page. if you're writing an app, there is a .NET library. If you are running from a script, there are command line tools. Either way, DotNetZip requires .NET. You will need Mono to run it on Linux.

example for the command line:

zipit.exe Olivier.zip -cp 860 test-éàïù.txt 

(to use the 860 codepage) I'm not sure that Windows Explorer correctly handles zipfiles with alternate encoding for the filenames within the zips.

See How to zip specified folders with Command Line for more info on that zipit.exe tool.

like image 163
Cheeso Avatar answered Nov 17 '25 20:11

Cheeso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!