TextDecoderStream: encoding 屬性

Baseline 已廣泛支援

此功能已成熟,並可在多種裝置和瀏覽器版本上執行。自 2022 年 9 月起,所有瀏覽器都已支援此功能。

注意:此功能在 Web Workers 中可用。

TextDecoderStream 介面的 encoding 只讀屬性返回一個字串,其中包含特定解碼器使用的編碼演算法的名稱。

編碼由 建構函式label 引數設定,預設為 utf-8

包含編碼格式的小寫 ASCII 名稱的字串。

允許的值與 TextDecoder.encoding 中列出的值相同(編碼 API 編碼中的標籤)。

示例

TextDecoderStream 返回 encoding 的值。

js
stream = new TextDecoderStream();
console.log(stream.encoding); // returns the default "utf-8"

規範

規範
編碼
# dom-textdecoder-encoding

瀏覽器相容性