string to wchar*?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 3 22:46:32 PDT 2017


On Sun, Jun 04, 2017 at 12:45:23AM +0000, Stanislav Blinov via Digitalmars-d-learn wrote:
[...]
> No, it shouldn't. char* et al. are not string types in D.
> to!(char*)(string) just doesn't make sense.

If you need to convert between D strings and char*, wchar*, etc., e.g.,
for interfacing with C/C++ APIs, take a look at std.string.toStringz and
std.string.fromStringz.  Do not use casts or std.conv.to because D does
not treat character pointers as string, unlike C/C++.


T

-- 
Leather is waterproof.  Ever see a cow with an umbrella?


More information about the Digitalmars-d-learn mailing list