Wired question related with Chinese characters
Steven Schveighoffer
schveiguy at gmail.com
Sun Mar 22 15:53:29 UTC 2020
On 3/22/20 11:19 AM, walker wrote:
> I am new to dlang, I like it :)
> I am on windows10 and use the terminal preview to test and run programs.
>
> In order to print Chinese characters correctly, I always use
>
> void main()
> {
> string var1 = "你好"; # to!string(in_other_conditions)
> writeln(var1);
> }
>
> I tried dstring but not working. Need Help Here.
>
> ---------------------------------
> The wired thing is the above approach may not work sometimes ->
> corrupted characters show up.
>
> However, if I run in the same place a little program written in nim
> (just print hello world), then I run the same dlang program, the Chinese
> character is print correctly.
>
> Why that happened?
On windows, the default codepage for the terminal is NOT UTF8. Which
means it may not know how to properly deal with your output.
Most likely nim is making the terminal use the UTF8 codepage.
See more info here:
https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8
-Steve
More information about the Digitalmars-d-learn
mailing list