Skip to main content

text_decode

Function text_decode 

Source
pub(crate) fn text_decode(
    it: &mut Interp,
    this: Value,
    a: &[Value],
) -> Result<Value, Value>
Expand description

TextDecoder.prototype.decode(input, {stream})。

  • input は undefined(空)か BufferSource(ArrayBuffer・TypedArray・DataView)。それ以外は TypeError。
  • fatal: true で不正なバイト列に当たると TypeError(このとき復号器の状態も初期化する)。
  • {stream: true}: 末尾の不完全なシーケンス(UTF-8 は続きが来れば正しくなるものだけ、UTF-16 は奇数バイトと 上位サロゲート)を _pending に持ち越す。stream が偽なら残りを flush し、BOM の状態も初期化する。
  • ignoreBOM が偽のとき、復号の最初の出力の先頭にある U+FEFF(UTF-8/16)を落とす。