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

@@ -236,6 +236,8 @@ private:
bool LoadExtraInfo(const char* extraData, wxUint16 extraLen, bool localInfo);
wxUint16 GetInternalFlags(bool checkForUTF8) const;
wxUint8 m_SystemMadeBy; // one of enum wxZipSystem
wxUint8 m_VersionMadeBy; // major * 10 + minor
@@ -278,10 +280,10 @@ class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
public:
wxZipOutputStream(wxOutputStream& stream,
int level = -1,
wxMBConv& conv = wxConvLocal);
wxMBConv& conv = wxConvUTF8);
wxZipOutputStream(wxOutputStream *stream,
int level = -1,
wxMBConv& conv = wxConvLocal);
wxMBConv& conv = wxConvUTF8);
virtual WXZIPFIX ~wxZipOutputStream();
bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }