wxWidgets
wxWidgets copied to clipboard
Also use UTF-8 in wxString::wxString on Windows
Issue migrated from trac ticket # 18113
component: base | priority: normal
2018-03-28 14:10:51: jhasse created the issue
When porting a wxWidgets project from Linux to Windows I've noticed that stuff like
wxString foo("äüöß");
won't work there, as on Windows only the local encoding is accepted (Windows-1252 in my case), but on Linux it's UTF-8. You might argue now, that having UTF-8 (or anything non-ASCII) in string literals isn't valid C++, but the following is since C++11 (http://en.cppreference.com/w/cpp/language/string_literal) and also doesn't work (on Windows):
wxString foo(u8"äüöß");
I'm now using
wxString foo = wxString::FromUTF8(u8"äöüß");
as a work around, but it's a lot more to type and I often miss it when the implicit constructor gets used (e.g. passing a literal to a function accepting wxString).
So my suggestion would be to make the implicit wxString constructor assume UTF-8 on Windows, too. Maybe there is already a way to configure for this which I've missed?