Fix std::ostream::operator<<(wxScopedWCharBuffer)
This never worked correctly as using operator<<() with wchar_t pointer just fell back to the overload for void pointers, i.e. printed out the address of the wide string, which wasn't especially useful, but with C++20 it doesn't even compile, as this overload is explicitly deleted. Fix both problems at once by actually doing something useful for it instead and printing out data in either current encoding or UTF-8 if converting it to the current encoding failed.
This commit is contained in:
parent
176b9dde90
commit
63626acbe4
@ -4030,9 +4030,7 @@ namespace std
|
|||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&);
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedCharBuffer&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedCharBuffer&);
|
||||||
#ifndef __BORLANDC__
|
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
||||||
|
|
||||||
|
@ -207,12 +207,14 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedCharBuffer& str)
|
|||||||
return os << str.data();
|
return os << str.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __BORLANDC__
|
|
||||||
wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str)
|
wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str)
|
||||||
{
|
{
|
||||||
return os << str.data();
|
// There is no way to write wide character data to std::ostream directly,
|
||||||
|
// but we need to define this operator for compatibility, as we provided it
|
||||||
|
// since basically always, even if it never worked correctly before. So do
|
||||||
|
// the only reasonable thing and output it as UTF-8.
|
||||||
|
return os << wxConvWhateverWorks.cWC2MB(str.data());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user