TextDecoder class
WHATWG Encoding StandardTextDecoder API の実装。
const decoder = new TextDecoder();
const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
console.log(decoder.decode(u8arr)); // Hello
プロパティ
| encoding |
|
| fatal | デコード エラーによって |
| ignoreBOM | デコード結果にバイトオーダーマークが含まれる場合、値は |
メソッド
| decode(null | Array |
|
コンストラクターの詳細
TextDecoder(string, { fatal?: boolean, ignoreBOM?: boolean })
new TextDecoder(encoding?: string, options?: { fatal?: boolean, ignoreBOM?: boolean })
パラメーター
- encoding
-
string
- options
-
{ fatal?: boolean, ignoreBOM?: boolean }
プロパティの詳細
encoding
TextDecoder インスタンスでサポートされるエンコード。
encoding: string
プロパティ値
string
fatal
デコード エラーによって true がスローされた場合、値は TypeError されます。
fatal: boolean
プロパティ値
boolean
ignoreBOM
デコード結果にバイトオーダーマークが含まれる場合、値は true されます。
ignoreBOM: boolean
プロパティ値
boolean
メソッドの詳細
decode(null | ArrayBuffer | ArrayBufferView, { stream?: boolean })
input をデコードし、文字列を返します。
options.stream が trueされている場合、input の最後に発生する不完全なバイト シーケンスは内部的にバッファリングされ、次の textDecoder.decode()呼び出しの後に出力されます。
textDecoder.fatal が true場合、発生したエラーをデコードすると、TypeError がスローされます。
function decode(input?: null | ArrayBuffer | ArrayBufferView, options?: { stream?: boolean }): string
パラメーター
- input
-
null | ArrayBuffer | ArrayBufferView
エンコードされたデータを含む ArrayBuffer、DataView、または TypedArray インスタンス。
- options
-
{ stream?: boolean }
戻り値
string