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.
This commit is contained in:
parent
fa8a482593
commit
837e6d186d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user