Sorry for the late reply. Just found this email among the noise.

I indeed recently found the same discrepancy between the decoder's doc and
implementation. Moreover, decoders do not always return an error on invalid
input. There seems to be some pattern/system, but I'm not sure what it is.

I recently changed the Encoders to return errors. There is no single method
of replacement that is generally applicable so there is no way around this.
There are now two different decorators for handling errors. See CL

We could do a similar thing for Decoding. However, it is a bit more tricky
to do for Decoders (how many bytes should be gobbled per error). Also,
unlike with encoders, decoders should not return an error by default. This
makes the "decorator" technique used for encodings less suitable.

I think it would be fine for Decoders to simply never returning an error,
as the documentation suggests (one can always scan for U+FFFD), but it
would be good to know if people could use the errors or why different
errors were handled differently in the first place.

On Mon, Dec 7, 2015 at 3:48 AM, Nigel Tao wrote:

I remember, a year or three ago, discussing whether or not Encoding
transformers should return an error early, use a substitute character,
or be configurable between the two. I can't remember the details,
though. Marcel, do you?

Maybe we thought that people could write their own ForceDecode
function if they wanted to, although I'd make it a function that
returned a Transformer. Perhaps such a beast should live in

In any case, it seems like a bug that the NewDecoder docs don't match
the implementation. One or the other should change.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupgolang-nuts @
postedDec 2, '15 at 3:21p
activeDec 19, '15 at 2:40p

3 users in discussion

Rin Tohsaka: 1 post Nigel Tao: 1 post Mpvl: 1 post



site design / logo © 2022 Grokbase