Something about Chinese Disorder Code
BLM768 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 24 09:08:33 PST 2015
On Tuesday, 24 November 2015 at 09:48:45 UTC, magicdmer wrote:
> I display chinese string like:
>
> auto str = "你好,世界"
> writeln(str)
>
> and The display is garbled。
>
> some windows api like MessageBoxA ,if string is chinese, it
> displays disorder code too
>
> i think i must use WideCharToMultiByte to convert it , is there
> any other answer to solve this question simplely
You can also try using a wide string literal, i.e. "你好,世界"w. The
suffix forces the string to use 16-bit characters.
The garbled display from writeln might be related to your console
settings. If you aren't using the UTF-8 codepage in cmd.exe, that
would explain why the text appears garbled. Unfortunately,
Windows has some significant bugs with UTF-8 in the console.
More information about the Digitalmars-d-learn
mailing list