On Sunday, 8 February 2015 at 06:26:38 UTC, Ali Çehreli wrote:
On 02/07/2015 09:57 PM, Lave Zhang wrote:
Hi,
My first D program is like this:
-----------------------------------
import std.stdio;
void main(string[] args)
{
dstring s1 = "hello你好"d;
writeln(s1);
}
-----------------------------------
But the output is not correct(and my console codepage is 936):
C:\D\dmd2\samples\d>dmd hello.d -offilename hello.exe
C:\D\dmd2\samples\d>hello.exe
hello浣犲ソ
thanks.
This thread may be useful:
http://forum.dlang.org/thread/suzymdzjeifnfirtb...@dfeed.kimsufi.thecybershadow.net#post-suzymdzjeifnfirtbnrc:40dfeed.kimsufi.thecybershadow.net
Ali
Thanks, my problem has been solved:)
---------------------------------------
import std.stdio;
import core.stdc.wchar_;
extern(C) int setlocale(int, char*);
static this()
{
fwide(core.stdc.stdio.stdout, 1);
setlocale(0, cast(char*)"china");
}
int main(string[] args)
{
string s1 = "hello你好";
writefln("%s", s1);
return 0;
}