Re: [whatwg/encoding] ISO-2022-JP does not reset state when returning error (Issue #358)

ChALkeR left a comment (whatwg/encoding#358)

My take is continuing streaming after a fatal mode has thrown an error is a very bad idea, regardless of the encoding, and should be just forbidden for all encodings.

Demos on utf-16:
```js
const x = Uint8Array.of(1, 0xd8, 42, 0, 43, 0, 47, 0)
for (const fatal of [false, true]) {
  console.log({ fatal })
  const d = new TextDecoder('utf-16le', { fatal })
  const chunk = (arr, stream) => {
    try {
      console.log(escape(d.decode(arr, { stream })))
    } catch {
      console.log('ERR')
    }
  }

  chunk(x.subarray(0, 5), true)
  chunk(x.subarray(5, 7), true)
  chunk(x.subarray(7))
}
```

Results in Chrome and Firefox/WebKit are different. And I would argue and both actually make no sense

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

Message ID: <whatwg/encoding/issues/358/3678609602@github.com>

Received on Sunday, 21 December 2025 08:56:58 UTC