wchar* to char[]

doob doobnet at gmail.com
Fri Feb 8 06:17:36 PST 2008


Sergey Gromov wrote:
> 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*)".
> 
  My bad, it was only for char*


More information about the Digitalmars-d-learn mailing list