Use strict UTF-8 conversion in wxSafeConvertXXX() functions

It doesn't make sense to use any fallbacks when converting to/from UTF-8 and
this wasn't even done consistently as only wxSafeConvertWX2MB() used
MAP_INVALID_UTF8_TO_OCTAL, but not wxSafeConvertMB2WX().

More importantly, UTF-8 conversion can never fail for a valid Unicode string,
so there is no need for any fall backs.
This commit is contained in:
Vadim Zeitlin 2016-02-13 17:03:47 +01:00
parent 0d7f51098d
commit 90eae99cd6
2 changed files with 3 additions and 4 deletions

View File

@ -652,8 +652,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
// next if it fails and, finally, wxConvISO8859_1 which always succeeds
extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s);
// this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL)
// if it fails
// this function uses wxConvLibc and wxConvUTF8 if it fails
extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws);
#else // ANSI
// no conversions to do

View File

@ -3295,7 +3295,7 @@ wxWCharBuffer wxSafeConvertMB2WX(const char *s)
wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s));
if ( !wbuf )
wbuf = wxMBConvUTF8().cMB2WX(s);
wbuf = wxConvUTF8.cMB2WX(s);
if ( !wbuf )
wbuf = wxConvISO8859_1.cMB2WX(s);
@ -3309,7 +3309,7 @@ wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
wxCharBuffer buf(wxConvLibc.cWX2MB(ws));
if ( !buf )
buf = wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL).cWX2MB(ws);
buf = wxConvUTF8.cWX2MB(ws);
return buf;
}