what's the proper way to convert wchar[] to string?
Marc
jckj33 at gmail.com
Wed Jan 3 19:04:21 UTC 2018
On Wednesday, 3 January 2018 at 18:59:39 UTC, Ali Çehreli wrote:
> On 01/03/2018 10:50 AM, Marc wrote:
>> when calling winapi functions, usually you to deal with the
>> result in wchar[]. How do I convert it to string in D to be
>> usable by the application? does D have a native for this?
>
> std.conv has to and text:
>
> auto s0 = w.text;
> auto s1 = w.to!string;
>
> Ali
whoa, that simple. I've tried to!string(w) before, but I realized
the mistake I was passing the whole buffer rather:
> string s = w[0 .. wcslen(w.ptr)].to!string;
Thanks.
More information about the Digitalmars-d-learn
mailing list