mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Merge pull request #1039 from RobinD42/fix-issue969
Ensure all text goes into MemoryFSHandler files as utf-8 data
(cherry picked from commit b8a922ef46)
This commit is contained in:
@@ -146,6 +146,14 @@ Changes in this release include the following:
|
||||
* Moved the wxpy_api.h file into the wx package at wx/include/wxPython so it
|
||||
will be included in the wheel file. (#961)
|
||||
|
||||
* Fixed how string data is added to a virtual file-like object in
|
||||
wx.MemoryFSHandler. All strings are now added to the file as utf-8 encoded data,
|
||||
in both Python2 and Python3, and will be read from the virtual file the same
|
||||
way. If you need to use some other encoding for some reason you can first
|
||||
convert the text to a bytesarray or other buffer protocol compatible object and
|
||||
then create the virtual file from that data. (#969)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -83,10 +83,17 @@ def run():
|
||||
_fixHandlerClass(c)
|
||||
c.addPrivateCopyCtor()
|
||||
|
||||
# Make some more python-friendly versions of the AddFile methods accepting raw data
|
||||
c.find('AddFile').findOverload('binarydata').ignore()
|
||||
c.find('AddFileWithMimeType').findOverload('binarydata').ignore()
|
||||
# Make some more python-friendly versions of the AddFile methods accepting text or raw data
|
||||
c.find('AddFile').findOverload('textdata').ignore()
|
||||
c.addCppMethod('void', 'AddFile', '(const wxString& filename, const wxString& textdata)',
|
||||
isStatic=True,
|
||||
doc="Add a file from text data, which will first be converted to utf-8 encoded bytes.",
|
||||
body="""\
|
||||
wxScopedCharBuffer buf = textdata->utf8_str();
|
||||
wxMemoryFSHandler::AddFile(*filename, (const char*)buf, strlen(buf));
|
||||
""")
|
||||
|
||||
c.find('AddFile').findOverload('binarydata').ignore()
|
||||
c.addCppMethod('void', 'AddFile', '(const wxString& filename, wxPyBuffer* binarydata)',
|
||||
isStatic=True,
|
||||
doc="Add a file from raw data in a python buffer compatible object.",
|
||||
@@ -94,6 +101,17 @@ def run():
|
||||
wxMemoryFSHandler::AddFile(*filename, binarydata->m_ptr, binarydata->m_len);
|
||||
""")
|
||||
|
||||
c.find('AddFileWithMimeType').findOverload('textdata').ignore()
|
||||
c.addCppMethod('void', 'AddFileWithMimeType',
|
||||
'(const wxString& filename, const wxString& textdata, const wxString& mimetype)',
|
||||
isStatic=True,
|
||||
doc="Add a file from text data, which will first be converted to utf-8 encoded bytes.",
|
||||
body="""\
|
||||
wxScopedCharBuffer buf = textdata->utf8_str();
|
||||
wxMemoryFSHandler::AddFileWithMimeType(*filename, (const char*)buf, strlen(buf), *mimetype);
|
||||
""")
|
||||
|
||||
c.find('AddFileWithMimeType').findOverload('binarydata').ignore()
|
||||
c.addCppMethod('void', 'AddFileWithMimeType',
|
||||
'(const wxString& filename, wxPyBuffer* binarydata, const wxString& mimetype)',
|
||||
isStatic=True,
|
||||
|
||||
Reference in New Issue
Block a user