This project is read-only.

Weird Unicode Issue.

May 12, 2010 at 1:51 AM
Edited May 12, 2010 at 1:52 AM

I am adding 1 file to a zip which is:


When I zip it I do this:

var zip = new ZipFile();          

zip.CompressionLevel = CompressionLevel.None;            

zip.UseUnicodeAsNecessary = true;

When I add a Entry I simply do this:

zip.AddEntry(Path.Combine(folderName, "Σελήνη.jpg"), stream);


If I open the ZipFile with WinRar everything is perfect, but if I open with Windows 7 default zip extractor/Windows Explorer or WinZip I get this:


Any ideas on how to fix this?

If I leave off zip.UseUnicodeAsNecessary = true; it wont even write the file out.



May 12, 2010 at 3:17 AM

Windows doesn't do Unicode encoding in ZIP files, as far as I know.

Read the documentation on UseUnicodeAsNecessary to get all the details. 

May 12, 2010 at 6:15 AM

The problem is if I leave UseUnicodeAsNecessary as false, then the files don't even show in Windows Explorer, if I unzip with WinRar it throws errors and will eventually extract the file with ____ in place, however the sub directory is not held. I wouldn't mind if it kept the ___ or even ??? in the name but it doesn't even show them.


May 12, 2010 at 4:54 PM
Edited May 12, 2010 at 4:57 PM

Windows Explorer doesn't do Unicode zip files.  Apparently neither does WinRar.  or is it WinZip?  I'm not clear - you at first said "everything is perfect" regarding WinRar, and then later you said  "if I unzip in WinRar it throws errors".  So ... not clear to me.
Windows Explorer can handle IBM437-encoded zip files, but that is unsatisfactory to encode arbitrary Greek characters, as you have discovered and pointed out.  

I can't do anything about how Windows Explorer handles zip files it doesn't understand. I can't do anything about WinRar or WinZip, either.

I'm not clear on exactly what your goal is, either.  What is it that you want?  If you want a zip file that can store entries with greek characters in the entry names, across all of those tools, I'm not sure it's possible. 

Some people have found that creating a zip that uses a non-compliant, non-Unicode code page allows the zip to be read in Windows Explorer and WinRar. I don't know about WinZip. 
To try that, use the ProvisionalAlternateEncoding property.  Specify your default codepage.
The documentation explains the caveats regarding the interoperability of zip files created in this way.

I'll be interested to hear the results of your tests.


May 12, 2010 at 10:13 PM


Sorry if I was a bit confusing. The overall goal was that I could put this file into a zip and I could unzip it in Windows Explorer/WinRar/Winzip and it would come out as the same file name. However I have read the documentation multiple times and done a lot of test and after reading what you have replied with it seems like this is not possible. Here is my testing:


If I zip this file and leave UseUnicodeAsNecessary as FALSE the following happens:

Windows Explorer: Can not open it.

WinRar/WinZip: Can open it, but has weird names, and the Sub Folders do not work at all which is a problem


iIf I set UseUnicodeAsNecessary to TRUE the following happens:

Windows Explorer: Can open it, but the file shows up as +ú+¦+++«++++.jpg

WinRar/WinZip: Can open it just fine and the file name is exactly the same. 


Something interesting is that if I simply try to use Windows Explorer to send this file to a compressed File(zip) it tells me: it cannot be compressed because it includes characters that cannot be used in a compressed folder and I should rename it.

I also did some testing in Gmail with similarly named files. Gmail allows you to download attachments as a zip and it automatically detects that the characters are valid for a zip file and asks you What country you would like to compress it for. Selecting English will take out all illegal characters and replace them with underscores. This is something that I wish the dot net zip library did for me. 

I have also tried changing the ProvisionalAlternateEncoding property and it seems as though I get very similar results. I think at this point this is really an edge case and that as long as the files come through I am fine with that. 

I am curious however as to if I was to create a zip file with japanese characters on a japanese version of Windows would it unzip just fine?


May 13, 2010 at 1:03 PM

For ProvisionalAlternateEncoding, I'm surprised to hear your results? 
Other users reported that Windows Explorer is able to read a zip file encoded in the machine's default code page.
I haven't tested that.  I don't have a machine wiith an alternate code page

I think older WinRar releases used to employ the machine's encoding by default.   This means a zip created with ProvisionalAlternateEncoding would just work in WinRar.

As for automagically replacing characters - I'll look into that.  

May 13, 2010 at 1:07 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
May 13, 2010 at 6:32 PM

Is there a code page that you would like me to try for ProvisionalAlternateEncoding?


May 14, 2010 at 2:58 PM

I don't know.  Is there a greek code page?   What's te default code page on your machine?

I don't have a machine with a non-US code page, so I don't know the secret.  I'm only relating what people have told me.