reverted the change of r56246 and keep the old behaviour of MB2WC/WC2MB; document it even more clearly and correct code using these functions incorrectly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@56394 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-10-17 11:31:22 +00:00
parent 2471348611
commit 753874333a
5 changed files with 36 additions and 34 deletions

View File

@@ -2252,8 +2252,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse
#else
wxMBConvUTF16 converter ;
ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ;
converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ;
wxASSERT_MSG( byteBufferLen != wxCONV_FAILED,
_T("Conversion to UTF-16 unexpectedly failed") );
UniChar *unibuf = (UniChar*)malloc( byteBufferLen + 2 ) ; // 2 for NUL in UTF-16
converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ;
TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
free( unibuf ) ;
#endif