Zip: Encoding filenames with non-ASCII characters

Setting the Encoding Configuration Option

Applies to: .NET, Java, Android, Xamarin

To ensure that filenames containing non-ASCII characters are encoded correctly, set the Encoding configuration option to UTF-8.

C# Zip zip = new Zip(); zip.Config("Encoding=UTF-8"); zip.ArchiveFile("C:\Test\Non_ASCII_Chars.zip"); zip.IncludeFiles("C:\Test\äöüß.txt"); zip.Compress();

Setting the CodePage Configuration Option

Applies to: C++, C++ Builder, Node.JS, Delphi, PHP, ActiveX/COM

To ensure that filenames containing non-ASCII characters are encoded correctly, set the CodePage configuration option to 65001 (4 for macOS) to specify UTF-8.

Node.JS var zip = new ipworkszip.zip(); zip.config("CodePage=65001"); zip.setArchiveFile("C:\Test\Non_ASCII_Chars.zip"); zip.includeFiles("C:\Test\äöüß.txt"); zip.compress();

Note: C++ requires the use of special component classes with wide character support on top of setting the CodePage configuration option. These classes have the same functionality, but their usage differs in two ways: the type name has a W appended to it (i.e., ZipW), and all string arguments passed to the class must be wide strings.

C++ ZipW zipw; zipw.Config(L"CodePage=65001"); zipw.SetArchiveFile(L"C:\Test\Non_ASCII_Chars.zip"); zipw.IncludeFiles(L"C:\Test\äöüß.txt"); zipw.Compress();

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.