Bug 30972 - System.IO.Compression.ZipArchive disregards provided encoding
Summary: System.IO.Compression.ZipArchive disregards provided encoding
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: João Matos
Depends on:
Reported: 2015-06-10 09:10 UTC by mz
Modified: 2015-06-11 13:21 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description mz 2015-06-10 09:10:46 UTC
Internal SharpCompress has a hardcoded UTF-8 encoding in 

The encoding provided in constructor to:
is saved into a variable and never actually used.
Comment 1 mz 2015-06-11 04:44:08 UTC
I have created a pull request for
that allows the encoding to be set via static ArchiveEncoding.Default field.

It is now merged in sharpcompress master.
Comment 2 João Matos 2015-06-11 10:48:42 UTC
Thanks for getting the ball rolling and getting that merged. I think we should be passing the encoding to ZipWriter's through its constructor though and not relying on the static value in ArchiveEncoding which could be changed at any time. This can lead to corrupted Zip archives if another thread changes the encoding while another is writing the archive.
Comment 3 mz 2015-06-11 11:01:00 UTC
The problem is such change would require a change in SharpCompress API.
It's hard to say if they'll accept the change as it might break people's programs using the library.

I don't think a concurent change would break the archive (we'd only have paths in different encodings).

I'd say we should go ahead with the change as it's fairly trivial, offers improvement and the corner case of multithreaded, multiencoding zipping shold be rather rare.
Comment 4 João Matos 2015-06-11 13:21:42 UTC
I fixed it in a slightly different way.


Please let me know if there's any problem.