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

Matthew Ong ongbp at yahoo.com
Sat May 21 00:06:11 PDT 2011


On 5/21/2011 2:46 PM, Matthew Ong wrote:
> 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.
>
Hi All,
correction on my part. It does seem like a font issue. Strangely the 
same console program that used to be able to show unicode correctly for 
both java and go is no longer working???

I think it is true, it has nothing to do with D. More like a font thing.

The result I got working is within the Eclipse Java and Go Console but 
NOT the DDT D console.

Without IDE, all of them show garbage...
Perhaps some one can kindly show me how the console fonts setting works 
for M$ Vista.

 >Unicode-aware font, maybe Lucida< How I tried Lucida it also does not 
work. There is only 2 fonts shown int the Command Prompt Properties Font 
Tab.

-- 
Matthew Ong
email: ongbp at yahoo.com



More information about the Digitalmars-d-learn mailing list