print ubyte[] as (ascii) string

Dukc ajieskola at gmail.com
Fri Jan 7 23:48:26 UTC 2022


On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote:
>
> ```d
> char[] s = cast(char[])ioCtx.buf[0 .. 
> strlen(cast(char*)ioCtx.buf.ptr) - 1];
> // -1 is to eliminate terminating '\n'
> writefln("got '%s' from '%s:%d'", s, client.addr, client.port);
> ```
>
> Is there some more concise/elegant way to do that?

Try `auto s = fromStringz(cast(char*)ioCtx.buf.ptr)`.




More information about the Digitalmars-d-learn mailing list