print ubyte[] as (ascii) string

eugene dee0xeed at gmail.com
Thu Dec 30 16:53:56 UTC 2021


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?

```d
char[] s = fromStringz(cast(char*)ioCtx.buf.ptr).strip;
writefln("got '%s' from '%s:%d'", s, client.addr, client.port);
```

Well, this will do:)



More information about the Digitalmars-d-learn mailing list