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:
@@ -652,8 +652,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
|
|||||||
// next if it fails and, finally, wxConvISO8859_1 which always succeeds
|
// next if it fails and, finally, wxConvISO8859_1 which always succeeds
|
||||||
extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s);
|
extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s);
|
||||||
|
|
||||||
// this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL)
|
// this function uses wxConvLibc and wxConvUTF8 if it fails
|
||||||
// if it fails
|
|
||||||
extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws);
|
extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws);
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
// no conversions to do
|
// no conversions to do
|
||||||
|
@@ -3295,7 +3295,7 @@ wxWCharBuffer wxSafeConvertMB2WX(const char *s)
|
|||||||
|
|
||||||
wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s));
|
wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s));
|
||||||
if ( !wbuf )
|
if ( !wbuf )
|
||||||
wbuf = wxMBConvUTF8().cMB2WX(s);
|
wbuf = wxConvUTF8.cMB2WX(s);
|
||||||
if ( !wbuf )
|
if ( !wbuf )
|
||||||
wbuf = wxConvISO8859_1.cMB2WX(s);
|
wbuf = wxConvISO8859_1.cMB2WX(s);
|
||||||
|
|
||||||
@@ -3309,7 +3309,7 @@ wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
|
|||||||
|
|
||||||
wxCharBuffer buf(wxConvLibc.cWX2MB(ws));
|
wxCharBuffer buf(wxConvLibc.cWX2MB(ws));
|
||||||
if ( !buf )
|
if ( !buf )
|
||||||
buf = wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL).cWX2MB(ws);
|
buf = wxConvUTF8.cWX2MB(ws);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user