From 90eae99cd6af53bbfd3a91cc9648339e43f731bd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Feb 2016 17:03:47 +0100 Subject: [PATCH] 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. --- include/wx/strconv.h | 3 +-- src/common/strconv.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 6b92a08384..12346c9763 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -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 diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 76c6df67a7..9e7da47925 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -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; }