added wxSafeConvertMB2WX/WX2MB() and use them when interfacing with C functions which crash if we pass them NULL pointers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44771 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3650,9 +3650,39 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = &
|
||||
#else
|
||||
wxConvUTF8Obj;
|
||||
#endif
|
||||
#else
|
||||
#else // !__WXOSX__
|
||||
wxConvLibcObj;
|
||||
#endif
|
||||
#endif // __WXOSX__/!__WXOSX__
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
|
||||
wxWCharBuffer wxSafeConvertMB2WX(const char *s)
|
||||
{
|
||||
if ( !s )
|
||||
return wxWCharBuffer();
|
||||
|
||||
wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s));
|
||||
if ( !wbuf )
|
||||
wbuf = wxConvUTF8.cMB2WX(s);
|
||||
if ( !wbuf )
|
||||
wbuf = wxConvISO8859_1.cMB2WX(s);
|
||||
|
||||
return wbuf;
|
||||
}
|
||||
|
||||
wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
|
||||
{
|
||||
if ( !ws )
|
||||
return wxCharBuffer();
|
||||
|
||||
wxCharBuffer buf(wxConvLibc.cWX2MB(ws));
|
||||
if ( !buf )
|
||||
buf = wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL).cWX2MB(ws);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif // wxUSE_UNICODE
|
||||
|
||||
#else // !wxUSE_WCHAR_T
|
||||
|
||||
|
Reference in New Issue
Block a user