[OT] Re: toStringz or not toStringz

Mike Parker aldacron at gmail.com
Fri Jul 8 08:42:34 PDT 2011


On 7/8/2011 11:03 PM, SimonM wrote:
> This is kind of off-topic, and I don't know if it's just me, but I've
> barely been able to use toStringz() where it's supposed to be useful:
>
> I tried using it with a C function whose parameters are not
> const(char)*, but just char*, but because it returns immutable(char)'s I
> had to write my own one.

someCFunc(cast(char*)myString.toStringz());

>
> I tried using it with a C function that's unicode, but it won't take
> wstring's as arguments... so I had to write my own one.

import std.utf;

some_wchar_func(myString.toUTF16z());

/* For non-const */
some_wchar_func_2(cast(wchar*)myString.toUTF16z());





More information about the Digitalmars-d mailing list