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

浏览器兼容性