www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - what's the proper way to convert wchar[] to string?

reply Marc <jckj33 gmail.com> writes:
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?
Jan 03
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Jan 03
parent Marc <jckj33 gmail.com> writes:
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.
Jan 03