diff --git a/docs/changes.txt b/docs/changes.txt index 2f3b03efcb..46febbaceb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -49,6 +49,7 @@ Changes in behaviour which may result in build errors All: +- Add UTF-8 support to wxZip{Input,Output}Stream (Tobias Taschner). - Allow calling wxItemContainer::Add() and similar with std::vector<> argument. - Add "%z" support to printf()-like functions like wxString::Format() (RIVDSL). - Add DOCTYPE support to wxXmlDocument (Nick Matthews). diff --git a/include/wx/zipstrm.h b/include/wx/zipstrm.h index da83986a49..9d66603aae 100644 --- a/include/wx/zipstrm.h +++ b/include/wx/zipstrm.h @@ -105,6 +105,7 @@ enum wxZipFlags wxZIP_ENHANCED = 0x0010, wxZIP_PATCH = 0x0020, wxZIP_STRONG_ENC = 0x0040, + wxZIP_LANG_ENC_UTF8 = 0x0800, // filename and comment are UTF8 wxZIP_UNUSED = 0x0F80, wxZIP_RESERVED = 0xF000 }; diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp index abc8f5051a..167e8abc51 100644 --- a/src/common/zipstrm.cpp +++ b/src/common/zipstrm.cpp @@ -984,7 +984,9 @@ size_t wxZipEntry::ReadLocal(wxInputStream& stream, wxMBConv& conv) if ((sumsValid || size) || m_Method == wxZIP_METHOD_STORE) m_Size = size; - SetName(ReadString(stream, nameLen, conv), wxPATH_UNIX); + wxMBConv& strConv = + ( (m_Flags & wxZIP_LANG_ENC_UTF8) == 0 ) ? conv : wxConvUTF8; + SetName(ReadString(stream, nameLen, strConv), wxPATH_UNIX); if (stream.LastRead() != nameLen + 0u) return 0; @@ -1052,7 +1054,9 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv) >> m_DiskStart >> m_InternalAttributes >> m_ExternalAttributes; SetOffset(ds.Read32()); - SetName(ReadString(stream, nameLen, conv), wxPATH_UNIX); + wxMBConv& strConv = + ((m_Flags & wxZIP_LANG_ENC_UTF8) == 0) ? conv : wxConvUTF8; + SetName(ReadString(stream, nameLen, strConv), wxPATH_UNIX); if (stream.LastRead() != nameLen + 0u) return 0; @@ -1066,7 +1070,7 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv) } if (commentLen) { - m_Comment = ReadString(stream, commentLen, conv); + m_Comment = ReadString(stream, commentLen, strConv); if (stream.LastRead() != commentLen + 0u) return 0; } else {