Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

UTF-8 does not reset state when returning error

オープン
#359 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript
領域
api, web-dev

調査の方向性

Start by reading issue #358 and the TextDecoder decode examples in this issue. Compare the reported Chrome, WebKit, Firefox, Node.js, Deno, and Bun behavior, then determine the intended handling of decoder errors and the “BOM seen” state; done means the Encoding Standard specifies the behavior consistently.

索引モデルが issue の本文から書いたものです。

説明

What is the issue with the Encoding Standard?

Same as #358 but for Unicode BOM
If the proposal of #358 is to reset state for errors, then what should happen to BOM seen?

I don't argue that it should be reset, but there is definitely some sort of issue and inconsistency there


Platform status is highly inconsistent:

const r = (d, ...a) => {
  try {
    return d.decode(...a).length
  } catch {}
  return 'e'
}

const a = new TextDecoder('utf8', { fatal: true })
console.log('A',
  r(a, Uint8Array.of(0xef, 0xbb, 0xbf, 0xff), { stream: true }),
  r(a, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }), // error does not stick in Chrome/Safari
)

const b = new TextDecoder('utf8', { fatal: true })
console.log('B',
  r(b, Uint8Array.of(0xef, 0xbb, 0xbf, 0xef), { stream: true }),
  r(b, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
  r(b, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }), // error sticks in Chrome / Safari
  r(b, Uint8Array.of(0xbb, 0xbf), { stream: true }),
  r(b, Uint8Array.of(), { stream: true }),
)

const c = new TextDecoder('utf8', { fatal: true })
console.log('C',
  r(c, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
  r(c, Uint8Array.of(0xff), { stream: true }),
  r(c, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
)

// Bonus: if BOM is not reset, is it processed on errors?
const d = new TextDecoder('utf8', { fatal: true })
const e = new TextDecoder('utf8', { fatal: true })
console.log('D',
  r(d, Uint8Array.of(0x20, 0xff), { stream: true }),
  r(d, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
  r(d, Uint8Array.of(0xff), { stream: true }),
  r(d, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
  r(e, Uint8Array.of(0xff), { stream: true }),
  r(e, Uint8Array.of(0xef, 0xbb, 0xbf), { stream: true }),
)

Chrome: first error did not get stuck, second error got stuck

A e 0
B 0 e e e e
C 0 e 1
D e 0 e 1 e 0

WebKit: first error did not get stuck, second error got stuck

A e 1
B 0 e e e e
C 0 e 1
D e 1 e 1 e 0

Firefox, Servo, Deno, Static Hermes: errors do not stick, bom does not get reset, bom seen is set on errors

A e 1
B 0 e 1 e 0
C 0 e 1
D e 1 e 1 e 1

Node.js: errors do not stick

A e 0
B 0 e 1 e 0
C 0 e 1
D e 0 e 1 e 0

Bun: just broken

A e 0
B 0 0 0 1 0
C 0 e 0
D e 0 e 0 e 0
主要言語
HTML
スター
323
フォーク
94
平均マージ
21分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

whatwg/encoding のほかの issue

whatwg/encoding の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。