new TextDecoder([encoding[, options]])


  • encoding <string> 识别此 TextDecoder 实例支持的 encoding默认值: 'utf-8'
  • options <Object>
    • fatal <boolean> true 如果解码失败是致命的。当 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.