diff options
Diffstat (limited to 'Source/JavaScriptCore/wtf/wx/StringWx.cpp')
-rw-r--r-- | Source/JavaScriptCore/wtf/wx/StringWx.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/Source/JavaScriptCore/wtf/wx/StringWx.cpp b/Source/JavaScriptCore/wtf/wx/StringWx.cpp index fe0fd89..d5f6c57 100644 --- a/Source/JavaScriptCore/wtf/wx/StringWx.cpp +++ b/Source/JavaScriptCore/wtf/wx/StringWx.cpp @@ -25,12 +25,15 @@ #include "config.h" -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - +// The wx headers must come first in this case, because the wtf/text headers +// import windows.h, and we need to allow the wx headers to set its configuration +// first. #include <wx/defs.h> #include <wx/string.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + namespace WTF { String::String(const wxString& wxstr) @@ -39,9 +42,10 @@ String::String(const wxString& wxstr) #error "This code only works in Unicode build of wxWidgets" #endif -#if SIZEOF_WCHAR_T == U_SIZEOF_UCHAR +#if SIZEOF_WCHAR_T == 2 - m_impl = StringImpl::create(wxstr.wc_str(), wxstr.length()); + const UChar* str = wxstr.wc_str(); + const size_t len = wxstr.length(); #else // SIZEOF_WCHAR_T == 4 @@ -58,13 +62,18 @@ String::String(const wxString& wxstr) #endif size_t wideLength = wxstr.length(); - UChar* data; wxMBConvUTF16 conv; - unsigned utf16Length = conv.FromWChar(0, 0, wideString, wideLength); - m_impl = StringImpl::createUninitialized(utf16Length, data); - conv.FromWChar((char*)data, utf16Length, wideString, wideLength); -#endif // SIZEOF_WCHAR_T == 4 + const size_t utf16bufLen = conv.FromWChar(0, 0, wideString, wideLength); + wxCharBuffer utf16buf(utf16bufLen); + + const UChar* str = (const UChar*)utf16buf.data(); + size_t len = conv.FromWChar(utf16buf.data(), utf16bufLen, wideString, wideLength) / 2; + +#endif // SIZEOF_WCHAR_T == 2 + + m_impl = StringImpl::create(str, len); + } String::operator wxString() const |