There seems to be several workarounds for handling zipfiles containing files with special characters, and I'd like to share mine.
My simple problem is that I have to extract zipfiles, most likely created using WinZip, which may contain files with names containing special characters - in my case, Danish letters like æøå/ÆØÅ.
SharpZip kept messing them up, no matter what value I set ZipConstants.DefaultCodePage to.
I made the following changes in ZipFile.cs:
The line [string name = ZipConstants.ConvertToStringExt(bitFlags, buffer, nameLen);]
was changed to:
int externallyDefinedCodepage = ZipConstants.DefaultCodePage;
if (versionMadeBy == 2836)
{
//Overrides DefaultCodePage to 1252 as mentioned at http://community.sharpdevelop.net/forums/thread/9246.aspx
ZipConstants.DefaultCodePage = System.Text.Encoding.Default.CodePage;
}
string name = ZipConstants.ConvertToStringExt(bitFlags, buffer, nameLen);
ZipConstants.DefaultCodePage = externallyDefinedCodepage;
Now I get my files extracted with the correct Danish characters.
I have not tested if this workaround has any negative/unexpected side effects, which I'd suspect it does, as ZipConstants.ConvertToStringEx() is also called in two other cases in that file - where I have not made any changes.
However, it makes SharpZip useful to me, and perhaps it can help others.
YMMV.