Content-Length: 174670 | pFad | http://developer.mozilla.org/ja/docs/Web/API/TextDecoderStream/TextDecoderStream

TextDecoderStream: TextDecoderStream() コンストラクター - Web API | MDN

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

TextDecoderStream: TextDecoderStream() コンストラクター

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2022年9月.

TextDecoderStream() コンストラクターは、新しい TextDecoderStream オブジェクトを生成します。これは、あるバイナリーエンコーディングのテキストのストリームを文字列に変換するために使用します。

構文

js
new TextDecoderStream(label)
new TextDecoderStream(label, options)

引数

label

文字列で、既定値は utf-8 です。 何れかの有効なラベルにすることができます。

options 省略可

次のプロパティを持つオブジェクトです。

fatal

論理値で、このオブジェクトが無効なデータをデコードした場合に TypeError を発生させる必要があるかどうかを示します。 既定値では false であり、これはデコードする際に不正なデータを置換文字で置き換えることを意味します。

例外

RangeError

label の値が未知の場合、または 'replacement' デコードアルゴリズム("iso-2022-cn" または "iso-2022-cn-ext")につながる値のいずれかである場合に発生します。

次の例は、fetch() の呼び出しから取得したバイナリーデータをデコードする方法を示しています。 このデータには label が渡されていないので、UTF-8 として解釈されます。

js
const response = await fetch("https://example.com");
const stream = response.body.pipeThrough(new TextDecoderStream());

仕様書

Specification
Encoding
# ref-for-dom-textdecoderstream①

ブラウザーの互換性









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://developer.mozilla.org/ja/docs/Web/API/TextDecoderStream/TextDecoderStream

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy