Hi,everyone,

Many Chinese coders found under Chinese characters were not display correctly under CodePage 936,but if use the Function CharToOemW,it's ok.

import std.c.stdio;
import std.c.windows.windows;
import std.stdio;

extern (Windows) {
    export BOOL CharToOemW(
            LPCWSTR lpszSrc, // string to translate
            LPSTR lpszDst // translated string
    );
}

void main()
{
wchar[] s =cast(wchar[]) "中文"; //Greek salutation //"Χαίρετε!"~
         writeln(s);
        echo(s,"");
}

void echo(wchar[] s,string page)
{
        //system("chcp "~page);
    char[] t = new char[s.length];
CharToOemW(cast(const(wchar)*)s, cast(char*)t); // calling Windows API function
    puts(cast(char*)t); // printing translated string
}

Now,it  displays correctly under 936.

So,writeln etc. function should use the Windows API Function on windows.
It's ok?

Frank

Reply via email to