(no title)
ormax3 | 2 years ago
::SetWindowTextW(widen(someStdString).c_str());
Implementation is straightforward, relying on `WideCharToMultiByte`/`MultiByteToWideChar` to do the conversion:ormax3 | 2 years ago
::SetWindowTextW(widen(someStdString).c_str());
Implementation is straightforward, relying on `WideCharToMultiByte`/`MultiByteToWideChar` to do the conversion:
mkoubaa|2 years ago
eco|2 years ago
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.
adzm|2 years ago
huhtenberg|2 years ago
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.
ormax3|2 years ago
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)
ynik|2 years ago
Someone1234|2 years ago
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.