Re: [whatwg/encoding] Encode hook not adequate (#235)

I think I have a proposal that works:

1. We change the "fatal" branch of https://encoding.spec.whatwg.org/#concept-encoding-process to return _result_ rather than a new error. This way the error's code point information remains preserved. (Perhaps also do some editorial cleanup, e.g., "if _result_ is [an] error")
2. We introduce a new specification hook, "encode or fail" that the URL Standard can use. It uses the "fatal" mode, but as opposed to "UTF-8 decode without BOM or fail" it returns what it decoded so far and an error if it hit one (as a tuple I suppose). It expects to be invoked again with an empty output buffer as long as it returns an error. This works because the only stateful encoding we have is effectively reset (at least after #236) at the point where it returns an error. (Alternatively we export "run", "encoder", and "error" so the URL Standard can use them directly, but that seems slightly less elegant.)

Thoughts appreciated!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/235#issuecomment-712820914

Received on Tuesday, 20 October 2020 12:42:38 UTC