fix for always terminating intermediate UniChar String for 4 bytes wchar_t
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26130 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8ed42a0688
commit
8471ea9033
@ -1331,13 +1331,16 @@ public:
|
||||
}
|
||||
ByteCount byteBufferLen = n * sizeof( UniChar ) ;
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
ubuf = (UniChar*) malloc( byteBufferLen ) ;
|
||||
ubuf = (UniChar*) malloc( byteBufferLen + 2 ) ;
|
||||
#else
|
||||
ubuf = (UniChar*) (buf ? buf : tbuf) ;
|
||||
#endif
|
||||
status = TECConvertText(m_MB2WC_converter, (ConstTextPtr) psz , byteInLen, &byteInLen,
|
||||
(TextPtr) ubuf , byteBufferLen, &byteOutLen);
|
||||
#if SIZEOF_WCHAR_T == 4
|
||||
// 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 ;
|
||||
res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
|
||||
free( ubuf ) ;
|
||||
|
Loading…
Reference in New Issue
Block a user