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:
@@ -281,7 +281,7 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
|
|||||||
if (format == wxDF_UNICODETEXT)
|
if (format == wxDF_UNICODETEXT)
|
||||||
{
|
{
|
||||||
// host native is UTF16
|
// host native is UTF16
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
return converter.WC2MB( NULL , GetText().c_str() , 0 ) + 2; // add space for trailing unichar 0
|
return converter.WC2MB( NULL , GetText().c_str() , 0 ) + 2; // add space for trailing unichar 0
|
||||||
}
|
}
|
||||||
else // == wxDF_TEXT
|
else // == wxDF_TEXT
|
||||||
@@ -296,7 +296,7 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
|
|||||||
if (format == wxDF_UNICODETEXT)
|
if (format == wxDF_UNICODETEXT)
|
||||||
{
|
{
|
||||||
// host native is UTF16
|
// host native is UTF16
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
size_t len = converter.WC2MB( NULL , GetText().c_str() , 0 ) ;
|
size_t len = converter.WC2MB( NULL , GetText().c_str() , 0 ) ;
|
||||||
wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
|
wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
|
||||||
memcpy( (char*) buf, (const char*) buffer , len + 2); // trailing unichar 0
|
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)
|
if (format == wxDF_UNICODETEXT)
|
||||||
{
|
{
|
||||||
// host native is UTF16
|
// host native is UTF16
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
SetText( converter.cMB2WX( (const char*) buf ) );
|
SetText( converter.cMB2WX( (const char*) buf ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -2116,7 +2116,7 @@ public:
|
|||||||
UniChar* szUniBuffer = (UniChar*) szUnConv;
|
UniChar* szUniBuffer = (UniChar*) szUnConv;
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
nBufSize = converter.WC2MB( NULL , szUnConv , 0 );
|
nBufSize = converter.WC2MB( NULL , szUnConv , 0 );
|
||||||
szUniBuffer = new UniChar[ (nBufSize / sizeof(UniChar)) + 1] ;
|
szUniBuffer = new UniChar[ (nBufSize / sizeof(UniChar)) + 1] ;
|
||||||
converter.WC2MB( (char*) szUniBuffer , szUnConv, nBufSize + sizeof(UniChar)) ;
|
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
|
// 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
|
// is not properly terminated we get random characters at the end
|
||||||
ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
|
ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
|
res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
|
||||||
free( ubuf ) ;
|
free( ubuf ) ;
|
||||||
#else
|
#else
|
||||||
@@ -2285,7 +2285,7 @@ public:
|
|||||||
ByteCount byteBufferLen = n ;
|
ByteCount byteBufferLen = n ;
|
||||||
UniChar* ubuf = NULL ;
|
UniChar* ubuf = NULL ;
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
size_t unicharlen = converter.WC2MB( NULL , psz , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , psz , 0 ) ;
|
||||||
byteInLen = unicharlen ;
|
byteInLen = unicharlen ;
|
||||||
ubuf = (UniChar*) malloc( byteInLen + 2 ) ;
|
ubuf = (UniChar*) malloc( byteInLen + 2 ) ;
|
||||||
|
@@ -1315,7 +1315,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
|||||||
UniCharCount chars = str.Length() ;
|
UniCharCount chars = str.Length() ;
|
||||||
UniChar* ubuf = NULL ;
|
UniChar* ubuf = NULL ;
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||||
|
@@ -1294,7 +1294,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
|||||||
UniCharCount chars = str.Length() ;
|
UniCharCount chars = str.Length() ;
|
||||||
UniChar* ubuf = NULL ;
|
UniChar* ubuf = NULL ;
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||||
@@ -1454,7 +1454,7 @@ void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *heigh
|
|||||||
UniCharCount chars = str.Length() ;
|
UniCharCount chars = str.Length() ;
|
||||||
UniChar* ubuf = NULL ;
|
UniChar* ubuf = NULL ;
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||||
@@ -1526,7 +1526,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
|
|||||||
UniCharCount chars = text.Length() ;
|
UniCharCount chars = text.Length() ;
|
||||||
UniChar* ubuf = NULL ;
|
UniChar* ubuf = NULL ;
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , text.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , text.wc_str() , 0 ) ;
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
|
||||||
|
@@ -1424,7 +1424,7 @@ wxString wxMacMLTEControl::GetStringValue() const
|
|||||||
SetHandleSize( theText , ( actualSize + 1 ) * sizeof( UniChar ) ) ;
|
SetHandleSize( theText , ( actualSize + 1 ) * sizeof( UniChar ) ) ;
|
||||||
HLock( theText ) ;
|
HLock( theText ) ;
|
||||||
(((UniChar*)*theText)[actualSize]) = 0 ;
|
(((UniChar*)*theText)[actualSize]) = 0 ;
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
|
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
|
||||||
ptr = new wxChar[noChars + 1] ;
|
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,
|
TXNSetData( m_txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2,
|
||||||
start, end);
|
start, end);
|
||||||
#else
|
#else
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ;
|
ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ;
|
||||||
UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ;
|
UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ;
|
||||||
converter.WC2MB( (char*) unibuf , st.wc_str() , 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
|
#if SIZEOF_WCHAR_T == 2
|
||||||
uniChar = charBuf[0] ;
|
uniChar = charBuf[0] ;
|
||||||
#else
|
#else
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( dataSize > 4 )
|
if ( dataSize > 4 )
|
||||||
|
@@ -648,7 +648,7 @@ void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding )
|
|||||||
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
(UniChar*)str.wc_str() , str.Len() );
|
(UniChar*)str.wc_str() , str.Len() );
|
||||||
#else
|
#else
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
||||||
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
||||||
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
||||||
@@ -679,7 +679,7 @@ wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding)
|
|||||||
UniChar* unibuf = new UniChar[ cflen + 1 ] ;
|
UniChar* unibuf = new UniChar[ cflen + 1 ] ;
|
||||||
CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;
|
CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;
|
||||||
unibuf[cflen] = 0 ;
|
unibuf[cflen] = 0 ;
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16 converter ;
|
||||||
noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
|
noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
|
||||||
buf = new wxChar[ noChars + 1 ] ;
|
buf = new wxChar[ noChars + 1 ] ;
|
||||||
converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
|
converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
|
||||||
|
Reference in New Issue
Block a user