new TextDecoder([encoding[, options]])


  • encoding <string> 指定此 TextDecoder 实例支持的 encoding默认值: 'utf-8'
  • options <Object>
    • fatal <boolean> 如果解码失败是否致命。 当禁用 ICU 时不支持此选项(参见 国际化)。 默认值: false
    • ignoreBOM <boolean> 当为 true 时,TextDecoder 会在解码结果中包含字节顺序标记。 当为 false 时,字节顺序标记将从输出中移除。此选项仅在 encoding'utf-8''utf-16be''utf-16le' 时使用。默认值: false

创建一个新的 TextDecoder 实例。encoding 可以指定支持的编码之一或其别名。

【Creates a new TextDecoder instance. The encoding may specify one of the supported encodings or an alias.】

TextDecoder 类也可以在全局对象上使用。

【The TextDecoder class is also available on the global object.】