mb2wc fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ad9835c97c
commit
f309770945
@ -1574,9 +1574,11 @@ wxString wxMacMLTEControl::GetStringValue() const
|
||||
(((UniChar*)*theText)[actualSize]) = 0 ;
|
||||
wxMBConvUTF16 converter ;
|
||||
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
|
||||
wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
|
||||
ptr = new wxChar[noChars + 1] ;
|
||||
|
||||
noChars = converter.MB2WC( ptr , (const char*)*theText , noChars ) ;
|
||||
noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ;
|
||||
wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
|
||||
ptr[noChars] = 0 ;
|
||||
HUnlock( theText ) ;
|
||||
#endif
|
||||
|
@ -122,7 +122,10 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
||||
focus = (wxTopLevelWindowMac*) data ;
|
||||
|
||||
unsigned char charCode ;
|
||||
wxChar uniChar = 0 ;
|
||||
wxChar uniChar[2] ;
|
||||
uniChar[0] = 0;
|
||||
uniChar[1] = 0;
|
||||
|
||||
UInt32 keyCode ;
|
||||
UInt32 modifiers ;
|
||||
Point point ;
|
||||
@ -133,21 +136,23 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
||||
if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
|
||||
{
|
||||
UniChar buf[2] ;
|
||||
int numChars = dataSize / sizeof( UniChar) + 1;
|
||||
|
||||
UniChar* charBuf = buf ;
|
||||
|
||||
if ( dataSize > 4 )
|
||||
charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
|
||||
if ( numChars * 2 > 4 )
|
||||
charBuf = new UniChar[ numChars ] ;
|
||||
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
|
||||
charBuf[ numChars - 1 ] = 0;
|
||||
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
uniChar = charBuf[0] ;
|
||||
#else
|
||||
wxMBConvUTF16 converter ;
|
||||
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
||||
converter.MB2WC( &uniChar , (const char*)charBuf , 2 ) ;
|
||||
#endif
|
||||
|
||||
if ( dataSize > 4 )
|
||||
if ( numChars * 2 > 4 )
|
||||
delete[] charBuf ;
|
||||
}
|
||||
#endif
|
||||
@ -167,7 +172,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
||||
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
|
||||
wxTheApp->MacSetCurrentEvent( event , handler ) ;
|
||||
if ( /* focus && */ wxTheApp->MacSendKeyDownEvent(
|
||||
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
||||
focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
|
||||
{
|
||||
result = noErr ;
|
||||
}
|
||||
@ -177,7 +182,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
||||
|
||||
case kEventRawKeyUp :
|
||||
if ( /* focus && */ wxTheApp->MacSendKeyUpEvent(
|
||||
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
||||
focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
|
||||
{
|
||||
result = noErr ;
|
||||
}
|
||||
|
@ -681,8 +681,10 @@ wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding)
|
||||
unibuf[cflen] = 0 ;
|
||||
wxMBConvUTF16 converter ;
|
||||
noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
|
||||
wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
|
||||
buf = new wxChar[ noChars + 1 ] ;
|
||||
converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
|
||||
noChars = converter.MB2WC( buf , (const char*)unibuf , noChars + 1 ) ;
|
||||
wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
|
||||
delete[] unibuf ;
|
||||
#endif
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user