applying 1890924
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51656 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -610,12 +610,23 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN
|
|||||||
(UniChar*)str.wc_str() , str.Len() ) );
|
(UniChar*)str.wc_str() , str.Len() ) );
|
||||||
#else
|
#else
|
||||||
wxMBConvUTF16 converter ;
|
wxMBConvUTF16 converter ;
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
|
size_t unicharbytes = converter.FromWChar( NULL , 0 , str.wc_str() , str.Length() ) ;
|
||||||
UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
|
wxASSERT( unicharbytes != wxCONV_FAILED );
|
||||||
converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
|
if ( unicharbytes == wxCONV_FAILED )
|
||||||
reset( CFStringCreateWithCharacters( kCFAllocatorDefault ,
|
{
|
||||||
unibuf , unicharlen / sizeof(UniChar) ) );
|
// create an empty string
|
||||||
delete[] unibuf ;
|
reset( wxCFRetain( CFSTR("") ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// unicharbytes: number of bytes needed for UTF-16 encoded string (without terminating null)
|
||||||
|
// unichars: number of UTF-16 characters (without terminating null)
|
||||||
|
size_t unichars = unicharbytes / sizeof(UniChar) ;
|
||||||
|
UniChar *unibuf = new UniChar[ unichars ] ;
|
||||||
|
converter.FromWChar( (char*)unibuf , unicharbytes , str.wc_str() , str.Length() ) ;
|
||||||
|
reset( CFStringCreateWithCharacters( kCFAllocatorDefault , unibuf , unichars ) ) ;
|
||||||
|
delete[] unibuf ;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#else // not wxUSE_UNICODE
|
#else // not wxUSE_UNICODE
|
||||||
reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
reset( CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
|
||||||
|
Reference in New Issue
Block a user