Chinese characters display correctly under 936 after using the Function CharToOemW
FrankLike via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 16 20:17:44 PDT 2014
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
More information about the Digitalmars-d
mailing list