From 81bc750723a18f21cd17d1b173cd2a4dda9cea6e Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 24 May 2011 11:24:40 +0100 Subject: Merge WebKit at r80534: Intial merge by Git Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61 --- Source/JavaScriptCore/wtf/wx/StringWx.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'Source/JavaScriptCore/wtf/wx') 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 -#include - +// 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 #include +#include +#include + 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 -- cgit v1.1