For those who would like to print Chinese characters in windows console properly,below information for your easy reference.

After test,write works properly all the way,writeln only works properly when the args is no less than 2.writefln works properly all the way.

[code]
module cnsetlocale;

import core.stdc.wchar_;
import core.stdc.locale;

import std.stdio;
import std.string;
import std.conv;


extern(C) int setlocale(int, char*);   static this()   {
   fwide(core.stdc.stdio.stdout, 1);
setlocale(0, cast(char*)"china"); } int main(string[] args)
{
        printf("你好DMD2!!\n");
        writefln("%s","你好DMD2!!");
        string msg="你好DMD2!!";
        string msg1="很好很好的同学";
        string msg2="大大的了不起!";
        writefln("the string is %s",msg);
writefln("the string is %s \n %s\n%s and\n%s",msg,msg1,msg2,"很牛很牛");
        
        readln;
        return 0;
}
[/code]

Reply via email to