::SetWindowTextW(widen(someStdString).c_str());
Implementation is straightforward, relying on `WideCharToMultiByte`/`MultiByteToWideChar` to do the conversion: ::SetWindowTextW(widen(someStdString).c_str());
Implementation is straightforward, relying on `WideCharToMultiByte`/`MultiByteToWideChar` to do the conversion:I haven't tried it yet but with that you can just use the -A variants of the winapi with utf-8 strings. No conversion necessary.
If this cost really matters (and practically speaking it never does), then, as the other commenter said, the correct solution is to just use OS-native encoding for all file system paths and names used by the program, hidden behind an abstraction layer if needs be. UTF16 for Windows, UTF8 elsewhere.
The conversion overhead is really negligible: https://utf8everywhere.org/#faq.cvt.perf
(note: the two api calls per conversion is because how those specific functions work, first call to get the size to allocate, second to do the actual conversion, but you can always use another library in the implementation for the utf8<->utf16 conversion that might be more optimized than those windows api functions)
https://lemire.me/blog/2023/09/13/transcoding-unicode-string...
Someone is suggesting a way of making it less tedious, and your response is "performance?!" even though in both scenarios you're running the same code and it is likely the compiler in release would remove the intermediary.
No, that's not what I said.