Add support for UTF8 filenames in wxZipOutputStream

Zip filenames containing non ASCII characters will be marked with
bit 11 in the general purpose flags and will use UTF-8 encoding.

By only setting the flag when non ASCII characters are used the
created archives should be binary identical to previous versions.

The old behavior can be achieved by explicitly using wxConvLocal
with the constructor. This should also ensure that
existing code using a custom wxMBConv should work as before.
This commit is contained in:
Tobias Taschner
2017-10-22 22:34:56 +02:00
parent 73a22766ee
commit fe77b2d593
4 changed files with 31 additions and 8 deletions

View File

@@ -479,11 +479,18 @@ public:
In a Unicode build the third parameter @a conv is used to translate
the filename and comment fields to an 8-bit encoding.
It has no effect on the stream's data.
Since version 3.1.1, filenames in the generated archive will be encoded
using UTF-8 and marked according to ZIP specification. To get the
previous behaviour wxConvLocal may be provided as the conv object.
Please note that not all unzip applications are fully ZIP spec
compatible and may not correctly decode UTF-8 characters. For the best
interoperability using only ASCII characters is the safest option.
*/
wxZipOutputStream(wxOutputStream& stream, int level = -1,
wxMBConv& conv = wxConvLocal);
wxMBConv& conv = wxConvUTF8);
wxZipOutputStream(wxOutputStream* stream, int level = -1,
wxMBConv& conv = wxConvLocal);
wxMBConv& conv = wxConvUTF8);
//@}
/**