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

rikki cattermole rikki at cattermole.co.nz
Sun Dec 22 06:25:42 UTC 2019


On 22/12/2019 7:11 PM, moth wrote:
> hi all.
> 
> been learning d for the last few years but suddenly realised...
> 
> when i use this code:
> 
> writeln('♥');
> 
> the output displayed on the windows command line is "ÔÖÑ" [it works fine 
> when piped directly into a text file, however].
> 
> i've looked about in this forum, but all that i could find was people in 
> 2016[!] saying the codepage had to be altered - clearly nonsense, since 
> Rust [which i am also learning] has no problem whatsoever displaying "♥".

This is not nonsense. This is the correct solution if that is what you 
intend for your program to do.

Not everybody will want this. They may have set the code page themselves 
in some way. It may not have even occurred within a D application!

Its best we leave it as the default to play nice with other applications 
and libraries.

> is there any function i can call or setting i can adjust to get D to do 
> the same, or do i have to wait for something to be fixed in the language 
> / compiler itself?
> 
> best regards
> 
> moth [su.angel-island.zone]
> 

Not a bug. This is a known issue on the Windows side for people new to 
developing natively for it.

I just checked the terminal emulator I use, ConEmu and yeah it doesn't 
have to do anything to make Unicode "just work" settings wise. Its 
conhost with its legacy which is what you are facing.


More information about the Digitalmars-d-learn mailing list