Something about Chinese Disorder Code

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 24 19:16:26 PST 2015


On 25/11/15 1:47 AM, Meta wrote:
> On Tuesday, 24 November 2015 at 09:52:21 UTC, Rikki Cattermole wrote:
>> On 24/11/15 10:48 PM, 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
>>
>> *A windows API functions are for ASCII only.
>> You need the *W varients which are unicode.
>> For this you could use std.conv : to.
>>
>> wstring text = "my str".to!wstring;
>>
>> Or at least I'm pretty sure that will work for you.
>
> I'm pretty sure you can just do:
>
> wstring text = "my string";
>
> Or
>
> auto text = "my string"w;

The second one is correct yes.
I'm just assuming that it isn't compiled into the executable.


More information about the Digitalmars-d-learn mailing list