D2 string conversion
Sam Hu
samhudotsamhu at gmail.com
Sat May 9 08:01:53 PDT 2009
Hello,
In D2 I tried to write a simple function which wrapps WIN32 API MessageBoxW,with which I can handle wide characters like Chinese .Below is my try:
import std.string;
import std.conv;
import std.c.windows.windows;
extern(Windows)int MessageBoxW(HWND,LPCSTR,LPCSTR,int);
int showMessage(wchar[] msg,wchar[ ] caption=cast(wchar[])"Application",int style=MB_OK|MB_ICONINFORMATION)
{
return MessageBoxW(null,to!(const(char)[])(msg),to!(const(char)[])(caption),style);//try one
return MessageBoxW(null,toStringz(to!(const(char[])(msg)),toStringz(to!(const(char)[])(caption)),style);//try two
}
But both *try one* and *try two* the above are wrong.Anyone can figure me out what's the problem and what's the right way to do would be appreciated.
Sam
More information about the Digitalmars-d-learn
mailing list