On Thu Aug 3 07:27:22 2023 +0000, Hans Leidekker wrote:
Can you give an example where wprintf() doesn't do the right thing?
Printing a non-english username.
`wprintf()` by default doesn't print non-english letters at all (I remember testing various system LC_ALL variants, like `C.UTF-8`, `en_US.UTF-8`, `ru_RU.UTF-8`, and none of that took an effect).
With `setlocale(LC_ALL, something)` it does print the letters, but 1. Only of a language that is set, so I presume it chooses something like a `cp1251` equivalent (an 8-bit language-specific encoding?). 2. It isn't used in any of other wine programs, while that `ConsoleWriteW()` hack is used at least in present whoami and xcopy implementations (probably more).
This implementation, in turn, behaves exactly like the Windows whoami.
Also when testing the `klist` I noticed that on Windows it was printing `?` signs instead of `Server` string (somehow hooked up a translation?), so `ConsoleWriteW()` seems to be necessary for any translatable console programs if one wants to avoid `setlocale()`.