denizzzka:

immutable ubyte[] valueBin = cast(immutable(ubyte[])) toStringz(s); // s is string type

Error: e2ir: cannot cast toStringz(s) of type immutable(char)* to type immutable(ubyte[])

One way to do it:


import std.stdio;
void main() {
    string s = "hello";
    auto valueBin = cast(immutable ubyte[])s.dup;
    writeln(valueBin);
}


But what are you trying to do?

Bye,
bearophile

Reply via email to