print ubyte[] as (ascii) string

Steven Schveighoffer schveiguy at gmail.com
Sat Jan 8 04:16:02 UTC 2022


On 1/7/22 5:04 PM, eugene wrote:
> On Friday, 7 January 2022 at 21:17:33 UTC, Steven Schveighoffer wrote:
>> In C you have one choice (printf), but that choice may not fit your 
>> needs.
> 
> There are 2 buffers (RX one and TX one, both of 'reasonable' size)
> (it's the effing echo-server, nothing more)

Irrelevant to how you log the data.

> * print content of RX-buffer, ommiting terminating '\n' ('\n' is the 
> 'end of request') to (log/journal file)/stdout/
> 
> * ouptut received 'message' back to client, _with_ terminating '\n'

Since the data is unmodified, then you can do this too after logging it 
without the `\n`. Two separate needs, both well handled by using ranges 
and algorithms.

Or if they don't suit you well enough, just write your own. Writing a 
wrapping range isn't hard.

-Steve


More information about the Digitalmars-d-learn mailing list