Add support for UTF8 filenames in wxZipInputstream.
Zip files may mark filenames and comments via bit 11 in the general purpose flags. If this flag is set use wxConvUTF8 instead of the default wxConv.
This commit is contained in:
committed by
Vadim Zeitlin
parent
79aea3a9a2
commit
0f39ea0963
@@ -49,6 +49,7 @@ Changes in behaviour which may result in build errors
|
|||||||
|
|
||||||
All:
|
All:
|
||||||
|
|
||||||
|
- Add UTF-8 support to wxZip{Input,Output}Stream (Tobias Taschner).
|
||||||
- Allow calling wxItemContainer::Add() and similar with std::vector<> argument.
|
- Allow calling wxItemContainer::Add() and similar with std::vector<> argument.
|
||||||
- Add "%z" support to printf()-like functions like wxString::Format() (RIVDSL).
|
- Add "%z" support to printf()-like functions like wxString::Format() (RIVDSL).
|
||||||
- Add DOCTYPE support to wxXmlDocument (Nick Matthews).
|
- Add DOCTYPE support to wxXmlDocument (Nick Matthews).
|
||||||
|
@@ -105,6 +105,7 @@ enum wxZipFlags
|
|||||||
wxZIP_ENHANCED = 0x0010,
|
wxZIP_ENHANCED = 0x0010,
|
||||||
wxZIP_PATCH = 0x0020,
|
wxZIP_PATCH = 0x0020,
|
||||||
wxZIP_STRONG_ENC = 0x0040,
|
wxZIP_STRONG_ENC = 0x0040,
|
||||||
|
wxZIP_LANG_ENC_UTF8 = 0x0800, // filename and comment are UTF8
|
||||||
wxZIP_UNUSED = 0x0F80,
|
wxZIP_UNUSED = 0x0F80,
|
||||||
wxZIP_RESERVED = 0xF000
|
wxZIP_RESERVED = 0xF000
|
||||||
};
|
};
|
||||||
|
@@ -984,7 +984,9 @@ size_t wxZipEntry::ReadLocal(wxInputStream& stream, wxMBConv& conv)
|
|||||||
if ((sumsValid || size) || m_Method == wxZIP_METHOD_STORE)
|
if ((sumsValid || size) || m_Method == wxZIP_METHOD_STORE)
|
||||||
m_Size = size;
|
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)
|
if (stream.LastRead() != nameLen + 0u)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -1052,7 +1054,9 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv)
|
|||||||
>> m_DiskStart >> m_InternalAttributes >> m_ExternalAttributes;
|
>> m_DiskStart >> m_InternalAttributes >> m_ExternalAttributes;
|
||||||
SetOffset(ds.Read32());
|
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)
|
if (stream.LastRead() != nameLen + 0u)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -1066,7 +1070,7 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (commentLen) {
|
if (commentLen) {
|
||||||
m_Comment = ReadString(stream, commentLen, conv);
|
m_Comment = ReadString(stream, commentLen, strConv);
|
||||||
if (stream.LastRead() != commentLen + 0u)
|
if (stream.LastRead() != commentLen + 0u)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user