wchar* to char[]
Sergey Gromov
snake.scaly at gmail.com
Wed Feb 6 22:02:34 PST 2008
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)]);
In Tango, this would be:
import tango.text.convert.Utf;
import tango.text.Util;
auto len = indexOf(src, '\u0000', uint.max);
char[] str = toString(src[0..len]);
--
SnakE
More information about the Digitalmars-d-learn
mailing list