実験的:これは実験的技術です。これを本番環境で使用する前に、ブラウザの互換性テーブルを注意深く確認してください。
その TextDecoder オブジェクトの特定のメソッドでデコードされた、パラメーターで指定されたテキストを含む DOMString を返します。→●、MS(en)
decoder | TextDecoder¶ | ||
---|---|---|---|
buffer オプション | デコードするテキストを含む ArrayBuffer または ArrayBufferView のいずれかです。 | ||
options オプション | 次のプロパティを持つ TextDecodeOptions ディクショナリーです。
|
HTML:
<p>Encoded value: <span id="encoded-value"></span></p> <p>Decoded value: <span id="decoded-value"></span></p>
JavaScript:
const encoder = new TextEncoder(); const array = encoder.encode('€'); // Uint8Array(3) [226, 130, 172] document.getElementById('encoded-value').textContent = array; const decoder = new TextDecoder(); const str = decoder.decode(array); // String "€" document.getElementById('decoded-value').textContent = str;
表示内容: |
表示内容: |