Converting from C const(dchar*) to dstring

Danyal Zia via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 24 10:37:41 PDT 2014


Hi, I like to print the strings from a C function that returns 
const(dchar*), but I can't make the conversion to dstring. I can 
convert vice versa by:

dstring text = "Hello";
const(dchar)* str = toUTFz!(const(dchar)*)(text);
// passing it to C function prints Hello

However, I don't have the idea how can I go the other way. I 
tried several methods such as using to!dstring, toUTF32 etc which 
compiles successfully however printing them gives address of them 
instead of text.

Thanks,

Danyal Zia


More information about the Digitalmars-d-learn mailing list