From 837e6d186d850ee01e5fd6fadd106a0aa02acd81 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 19 Feb 2016 02:34:20 +0100 Subject: [PATCH] Don't lose Unicode data when outputting wxString to std::ostream Fall back to UTF-8 rather than not outputting anything at all if the string is not representable in the current locale encoding. Even if we did try to handle this error by setting failbit, chances of anybody checking for it (especially on e.g. std::cout) were very low and the only possible workaround in practice would have been attempting to output the string in UTF-8 anyhow, so just do it ourselves. See #17358. --- src/common/string.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index 930b488162..feb6d8e501 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -191,13 +191,7 @@ static wxStrCacheStatsDumper s_showCacheStats; wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str) { #if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8 - const wxScopedCharBuffer buf(str.AsCharBuf()); - if ( !buf ) - os.clear(wxSTD ios_base::failbit); - else - os << buf.data(); - - return os; + return os << wxConvWhateverWorks.cWX2MB(str); #else return os << str.AsInternal(); #endif