UniChar being platform endian
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
48e8e90e91
commit
d9d488cf1b
@ -281,7 +281,7 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
return converter.WC2MB( NULL , GetText().c_str() , 0 ) + 2; // add space for trailing unichar 0
|
||||
}
|
||||
else // == wxDF_TEXT
|
||||
@ -296,7 +296,7 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
size_t len = converter.WC2MB( NULL , GetText().c_str() , 0 ) ;
|
||||
wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
|
||||
memcpy( (char*) buf, (const char*) buffer , len + 2); // trailing unichar 0
|
||||
@ -316,7 +316,7 @@ bool wxTextDataObject::SetData(const wxDataFormat& format,
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
SetText( converter.cMB2WX( (const char*) buf ) );
|
||||
}
|
||||
else
|
||||
|
@ -2116,7 +2116,7 @@ public:
|
||||
UniChar* szUniBuffer = (UniChar*) szUnConv;
|
||||
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
nBufSize = converter.WC2MB( NULL , szUnConv , 0 );
|
||||
szUniBuffer = new UniChar[ (nBufSize / sizeof(UniChar)) + 1] ;
|
||||
converter.WC2MB( (char*) szUniBuffer , szUnConv, nBufSize + sizeof(UniChar)) ;
|
||||
@ -2252,7 +2252,7 @@ public:
|
||||
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
|
||||
// is not properly terminated we get random characters at the end
|
||||
ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
|
||||
free( ubuf ) ;
|
||||
#else
|
||||
@ -2285,7 +2285,7 @@ public:
|
||||
ByteCount byteBufferLen = n ;
|
||||
UniChar* ubuf = NULL ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
size_t unicharlen = converter.WC2MB( NULL , psz , 0 ) ;
|
||||
byteInLen = unicharlen ;
|
||||
ubuf = (UniChar*) malloc( byteInLen + 2 ) ;
|
||||
|
@ -1315,7 +1315,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
||||
UniCharCount chars = str.Length() ;
|
||||
UniChar* ubuf = NULL ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
#if wxUSE_UNICODE
|
||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||
|
@ -1294,7 +1294,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
||||
UniCharCount chars = str.Length() ;
|
||||
UniChar* ubuf = NULL ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
#if wxUSE_UNICODE
|
||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||
@ -1454,7 +1454,7 @@ void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *heigh
|
||||
UniCharCount chars = str.Length() ;
|
||||
UniChar* ubuf = NULL ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
#if wxUSE_UNICODE
|
||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||
@ -1526,7 +1526,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
|
||||
UniCharCount chars = text.Length() ;
|
||||
UniChar* ubuf = NULL ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
#if wxUSE_UNICODE
|
||||
size_t unicharlen = converter.WC2MB( NULL , text.wc_str() , 0 ) ;
|
||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||
|
@ -1424,7 +1424,7 @@ wxString wxMacMLTEControl::GetStringValue() const
|
||||
SetHandleSize( theText , ( actualSize + 1 ) * sizeof( UniChar ) ) ;
|
||||
HLock( theText ) ;
|
||||
(((UniChar*)*theText)[actualSize]) = 0 ;
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
|
||||
ptr = new wxChar[noChars + 1] ;
|
||||
|
||||
@ -1896,7 +1896,7 @@ void wxMacMLTEControl::SetTXNData( const wxString& st , TXNOffset start , TXNOff
|
||||
TXNSetData( m_txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2,
|
||||
start, end);
|
||||
#else
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ;
|
||||
UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ;
|
||||
converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ;
|
||||
|
@ -188,7 +188,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
uniChar = charBuf[0] ;
|
||||
#else
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
||||
#endif
|
||||
if ( dataSize > 4 )
|
||||
|
@ -648,7 +648,7 @@ void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding )
|
||||
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||
(UniChar*)str.wc_str() , str.Len() );
|
||||
#else
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
||||
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
||||
@ -679,7 +679,7 @@ wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding)
|
||||
UniChar* unibuf = new UniChar[ cflen + 1 ] ;
|
||||
CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;
|
||||
unibuf[cflen] = 0 ;
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxMBConvUTF16 converter ;
|
||||
noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
|
||||
buf = new wxChar[ noChars + 1 ] ;
|
||||
converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
|
||||
|
Loading…
Reference in New Issue
Block a user