ProvisionalAlternateEncoding Property

DotNetZip

Ionic Zip Library v1.9.1.6 ProvisionalAlternateEncoding Property
ReferenceIonic.ZipZipInputStreamProvisionalAlternateEncoding
The text encoding to use when reading entries into the zip archive, for those entries whose filenames or comments cannot be encoded with the default (IBM437) encoding.
Declaration Syntax
C# Visual Basic Visual C++
public Encoding ProvisionalAlternateEncoding { get; set; }
Public Property ProvisionalAlternateEncoding As Encoding
	Get
	Set
public:
property Encoding^ ProvisionalAlternateEncoding {
	Encoding^ get ();
	void set (Encoding^ value);
}
Remarks

In its zip specification, PKWare describes two options for encoding filenames and comments: using IBM437 or UTF-8. But, some archiving tools or libraries do not follow the specification, and instead encode characters using the system default code page. For example, WinRAR when run on a machine in Shanghai may encode filenames with the Big-5 Chinese (950) code page. This behavior is contrary to the Zip specification, but it occurs anyway.

When using DotNetZip to read zip archives that use something other than UTF-8 or IBM437, set this property to specify the code page to use when reading encoded filenames and comments for each ZipEntry in the zip file.

This property is "provisional". When the entry in the zip archive is not explicitly marked as using UTF-8, then IBM437 is used to decode filenames and comments. If a loss of data would result from using IBM436 - specifically when encoding and decoding is not reflexive - the codepage specified here is used. It is possible, therefore, to have a given entry with a Comment encoded in IBM437 and a FileName encoded with the specified "provisional" codepage.

When a zip file uses an arbitrary, non-UTF8 code page for encoding, there is no standard way for the reader application - whether DotNetZip, WinZip, WinRar, or something else - to know which codepage has been used for the entries. Readers of zip files are not able to inspect the zip file and determine the codepage that was used for the entries contained within it. It is left to the application or user to determine the necessary codepage when reading zip files encoded this way. If you use an incorrect codepage when reading a zipfile, you will get entries with filenames that are incorrect, and the incorrect filenames may even contain characters that are not legal for use within filenames in Windows. Extracting entries with illegal characters in the filenames will lead to exceptions. It's too bad, but this is just the way things are with code pages in zip files. Caveat Emptor.

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)