unicode characters are not printed correctly on the windows command line?

Adam D. Ruppe destructionator at gmail.com
Sun Dec 22 22:04:20 UTC 2019


On Sunday, 22 December 2019 at 18:41:16 UTC, Steven Schveighoffer 
wrote:
> Phobos doesn't call the wrong function, libc does. Phobos uses 
> fwrite for output.

There is allegedly a way to set fwrite to do the translations on 
MSVCRT:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode?view=vs-2019

but trying it here it throws invalid parameter exception so idk.

Regardless, I'm pretty well of the opinion that fwrite is the 
wrong thing to do anyway. fwrite writes bytes to a file, but we 
want to write strings to the console. There's other functions 
that do that.

There is the worry of mixing stuff from C and keeping the buffer 
consistent, but it could always just flush() before doing its 
thing too. Or maybe even merge the buffers, idk what the MS 
runtime supports for that.

or maybe i'm missing something and _setmode is a viable solution.


But whatever we do, passing the buck isn't solving anything. 
Windows has supported Unicode console output since NT 4.0 in 
1996.. just have to call the right function, and whether it is 
Phobos calling it or druntime or the CRT, someone just needs to 
do it!


More information about the Digitalmars-d-learn mailing list