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:
Vadim Zeitlin
2007-03-11 23:38:42 +00:00
parent fe295b0d3e
commit 69c928ef47
5 changed files with 65 additions and 17 deletions

View File

@@ -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