1

Closed

ZipFile.Read does not preserve unicode filenames (with workaround)

description

DotNetZip 1.9.1.5
 
For the following code snippet:
using(ZipFile zip = ZipFile.Read(fileName))
{
zip.AddDirectory(dirPath); // add some more files
zip.Save(fileName);
}
 
If the zip previously had some utf8 filenames (originally saved by DotNetZip), those are lost in the next save.
 
The workaround:
using(ZipFile zip = ZipFile.Read(fileName))
{
foreach(ZipEntry entry in zip)
entry.UseUnicodeAsNecessary = true;
 
zip.AddDirectory(dirPath); // add some more files
zip.Save(fileName);
}
 
If autosetting UseUnicodeAsNecessary is unwanted for some reason, could Read() at least look for the "using UTF8" general purpose bit being set and then set the entry's encoding explicitly to UTF8?
Closed Jun 15, 2011 at 2:06 PM by Cheeso
fixed in changeset 79164. First binary with this fix: v1.9.1.6

comments

mike_hurley_1 wrote Dec 23, 2010 at 9:59 PM

To clarify, when I say that the utf8 filenames are lost, I mean the UTF8 bytes are interpreted by DotNetZip, WinRAR, and WinZIP as ASCII.

Cheeso wrote Jun 15, 2011 at 2:05 PM

Wow! I'm really surprised to see this bug. Seems sort of basic. Good catch. Thanks for reporting it.