Thread overview | |||||
---|---|---|---|---|---|
|
January 03, 2018 what's the proper way to convert wchar[] to string? | ||||
---|---|---|---|---|
| ||||
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? |
January 03, 2018 Re: what's the proper way to convert wchar[] to string? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc | 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
|
January 03, 2018 Re: what's the proper way to convert wchar[] to string? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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. |
Copyright © 1999-2021 by the D Language Foundation