To process this zip file, I explicitly specify the Danish code page when reading the zip:
var encoding = System.Text.Encoding.GetEncoding("da-DK"); using (var zipFile = ZipFile.Read(@"File_æøåÆØÅ.zip", encoding)) { zipFile.ExtractAll(@"File_æøåÆØÅ", ExtractExistingFileAction.OverwriteSilently); }
The reason you need to do this explicitly:
The zip specification allows you to use two text encodings for file names and comments in a zip file: IBM437 and UTF8. When one of these encoded encodings is used, the zipfile metadata explicitly indicates it. DotNetZip or any library can safely use the encoding specified in the zip file.
There is no way in a zip file to specify an encoding that is not one of the two. The zip specification does not provide a way to do this. Some zip libraries or tools create zip files that do not meet specifications in this regard; zip files use text encodings such as da-DK or CP950 or something else. Strictly speaking, they do not meet the specifications, but the tools still create them. Mail files like this are not uncommon.
In such cases, some libraries or tools assume that the encoding used in the zip file is the same as the default encoding on the machine. This is unsafe or guaranteed to work, but this assumption works in the small case - where the zip file was created by an unassembled library or tool on the local computer. If you create a text encoded zip file by default (incompatible) and then send it from Stockholm to Shanghai, you cannot use the “assume standard encoding” strategy while reading.
DotNetZip does not make this assumption. In cases where the zipfile uses an incompatible text encoding, the zip file does not contain any information about which encoding is used, therefore DotNetZip uses the standard encoding - IBM437 - to read the file. DNZ has no way of knowing that this is "wrong." If you want to override this behavior, you need to use the ZipFile.Read () method, which takes a different encoding.
All of this is described in the DotNetZip documentation , in particular in ZipFile.ProvisionalAlternateEncoding .
source share