wchar* to char[]

Sergey Gromov snake.scaly at gmail.com
Thu Feb 7 13:05:57 PST 2008


doob <doobnet at gmail.com> wrote:
> Sergey Gromov wrote:
> > Heinz <malagana15 at yahoo.es> wrote:
> >> Is there a way to convert a wchar* variable to char[]? I'm trying to use the Win32 API LoadStringW, wich takes a parameter a wchar*.
> > 
> > Assuming that `src' is a wchar* string, in Phobos it's like this:
> > 
> >   import std.utf;
> >   extern(C) uint wcslen(in wchar* str);	// a C runtime library function
> > 
> >   char[] str = toUTF8(src[0..wcslen(src)]);
> 
> I would do like this:
> 
> Phobos:
> 
> import std.string;
> import std.utf;
> 
> // alias for char[] (D 1.x)
> string str = toUTF8(toString(src));

In Phobos, there is no function "std.string.toString(wchar*)".

-- 
SnakE


More information about the Digitalmars-d-learn mailing list