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

Matthew Ong ongbp at yahoo.com
Fri May 20 23:46:19 PDT 2011


On 5/20/2011 2:55 PM, Russel Winder wrote:
> On Thu, 2011-05-19 at 22:37 +0200, Andrej Mitrovic wrote:
> [ . . . ]
>> You would also need a Unicode-aware font, maybe Lucida or something
>> similar. Typically fixed-point fonts used for programming have little
>> support for Unicode characters, and you would get back a black or
>> white box like "[]".
>
> Alternatively use a nice proportional font with Unicode support for code
> so it is more readable?
>
> Backward compatibility with 80x24 terminals is just so last millennium.
>
Hi All,

Thanks for the example code on the unicode issue.

hi Andrej,
version(Windows)
{
    import std.c.windows.windows;
    extern(Windows) BOOL SetConsoleOutputCP(UINT);
}

void main()
{
    version(Windows) SetConsoleOutputCP(65001);
    writeln("Hello, world; or Καλημέρα κόσμε; or こんにちは 世界");
}

I am running this on a M$ Vista Professional edition.

Unfortunately that code sample does not work... Please see attachment.

The reason I am testing this is to understand how the stream library works.

Console test is fundamental test to see if the language handles unicode 
within the source code itself automatically and display them correctly 
when it does file IO, network and also GUI level.

Normally in mordern languages it should, because that allow a developer 
to easily define a simple resource bundle file to loaded automatically 
within the same fragment of code. If not, then, there is going to be 
problem. I hope we do not need to write such code:

version(English){
    // some code
}version(Chinese_MainLand){
   // some other code
}version(Chinese_HongKong){
   // yet another code
}...etc

I have originally plan to send an attached screen shot but it is not 
working for the newsgroup. Perhaps someone can show me how to do that here.

-- 
Matthew Ong
email: ongbp at yahoo.com



More information about the Digitalmars-d-learn mailing list