UTF8 conversion wxString :: ToStdString ()

I am writing an application and I am using wxWidgets as the GUI. The main body of the application uses std::string

UTF8 as its encoding. I need a normal way to convert between wxString

and std::string

. I know about wxString::ToUTF8()

, but somewhat awkward to use (and inefficient I think since it returns some proxy object). There is a better method wxString::ToStdString()

, but if I understood correctly, it uses the current encoding of the locale. Is there a way to configure wxWidgets globally such that it uses UTF8 encoding when converting between wxString

and narrow char ( const char*

, std::string

)?

+3


source to share


1 answer


No, there is no way to do this, you will have to write your own helper function with ToUTF8()

or equivalent utf8_str()

. This will be inefficient in the sense that it will need to convert from UTF-32 or UTF-16 each time it is called, but this is unlikely to be a bottleneck.



0


source







All Articles