TextDecoderStream.encoding

Baseline Widely available

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

TextDecoderStream 接口的只读属性 encoding 返回一个字符串,其中包含指定的 encoder 使用的编码算法的名称。

一个小写的 ASCII 字符串。

示例

从一个 TextDecoderStream 返回 encoding 的值。

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

规范

Specification
Encoding
# dom-textdecoder-encoding

浏览器兼容性