C++ Logo


Advanced search

Re: [SG16] iconv-style interface for transcoding functions

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Thu, 28 Jan 2021 20:48:37 +0100
On 28/01/2021 20.22, JeanHeyd Meneide wrote:
> Dear Jens, Peter and Corentin,
> Small addendum: using my brain a little better, I realize that we
> could also change the return type of the function to size_t for the
> XsntoYsn(charX** input, charX* input_end, charY** output, charY*
> output_end) function.
> 0 or anything above is a "number of code units output" count. All
> errors would be size_t-cast negative integral values. This is not
> without precedent: C does this for many of its error codes, including
> the transcode functions today. It would, in practice, only exclude the
> very LARGEST buffers to take away the values (size_t)-1, (size_t)-2,
> (size_t)-3 and for the error values. We could also not have a
> "success" return code at all, and let users do input == input_end to
> know that all input had been successfully converted with any return
> value >= 0 that is also not any of the (size_t)-casted negative
> values.

Sounds reasonable.

> Of course, even as I describe possible schemes for this, it
> doesn't seem quite so clean, and still has the problem that, for
> example, input_end could never be NULL.

Not supporting unbounded buffers is feature, not a bug.


Received on 2021-01-28 13:48:46