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[])
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(i
On Monday, 29 October 2012 at 17:51:56 UTC, bearophile wrote:
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;
v
denizzzka:
I am trying to send to remote host utf8 text with zero byte at
end (required by protocol)
What if your UTF8 string coming from D already contains several
zeros?
toStringz(s) returns a pointer, so you can't cast a pointer (that
doesn't know the length the buffer it points to) to
On Monday, 29 October 2012 at 18:50:58 UTC, bearophile wrote:
denizzzka:
I am trying to send to remote host utf8 text with zero byte at
end (required by protocol)
What if your UTF8 string coming from D already contains several
zeros?
Incredible situation because it is text-based protocol
On Mon, 29 Oct 2012 19:50:57 +0100
"bearophile" wrote:
> denizzzka:
>
> > I am trying to send to remote host utf8 text with zero byte at
> > end (required by protocol)
>
> What if your UTF8 string coming from D already contains several
> zeros?
>
If you need to send a string with an embedde
denizzzka:
I am concerned about the extra allocations of temp arrays. here
is it, or not? compiler optimizes it?
There is one allocation, and usually the D compilers can't
optimize it away.
In my case it does not matter but for the future I would like
to know how it can be implemented wit