How to print unicode like: こ ん に ち は 世界

Robert Clipsham robert at octarineparrot.com
Thu May 19 10:46:24 PDT 2011


On 19/05/2011 16:19, Matthew Ong wrote:
> On 5/19/2011 11:22 PM, Matthew Ong wrote:
>> Hi,
>>
>> import std.stdio;
>> alias immutable(wchar)[] String;
>> String str="Hello, world;
>> orΚαλημέρακόσμε;
>> orこんにちは世界";
>> writeln(str); // It prints garbage on console.
>>
>> In Java and Go, that just works. I believe UTF-X is handles that.
>>
>> How to do that within D?
>>
>> Yes. I am still new to D. No. I am not japanese but chinese.
>>
>>
>> Matthew Ong
>>
>
> String str="Hello, world; or Καλημέρα κόσμε; or こんにちは 世界";
>

There is a built in alias for immutable(wchar)[], wstring. Try 
postfixing with w, eg:

wstring str = "Hello, world; or Καλημέρα κόσμε; or こんにちは 世界"w;

You could even use auto, given that you postfixed the string with w.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list