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

ChALkeR left a comment (whatwg/encoding#358)

E.g.:
```js
const x = Uint8Array.fromHex('00d800d80101003c007300630072006900700074003e0061006c006500720074002800310029003c002f007300630072006900700074003e0000')
for (const fatal of [false, true]) {
  console.log({ fatal })
  const d = new TextDecoder('utf-16le', { fatal })
  const chunk = (arr, stream) => {
    try {
      console.log(d.decode(arr, { stream }))
    } catch {
      console.log('ERR')
    }
  }

  chunk(x.subarray(0, 7), true)
  chunk(x.subarray(7, -1), true) // have we reset state before this call?
  chunk(x.subarray(-1))
}
```

(Behaves differently in Chrome and the rest)

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

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

Received on Monday, 22 December 2025 07:08:08 UTC