A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/zh-CN/docs/Web/API/TextDecoder/TextDecoder below:

TextDecoder() - Web API | MDN

TextDecoder()

Baseline Widely available

TextDecoder() 构造函数使用参数中指定的编码返回一个新创建的 TextDecoder 对象。

语法
new TextDecoder()
new TextDecoder(utfLabel)
new TextDecoder(utfLabel, options)
参数
utfLabel 可选

一个字符串,默认是 "utf-8"。可以是任意有效的编码。

options 可选

一个具有属性的对象:

fatal

一个布尔值,表示在解码无效数据时,TextDecoder.decode() 方法是否必须抛出 TypeError。默认是 false,这意味着解码器将用替换字符替换错误的数据。

异常
RangeError

如果 label 值是未知的,或是使用了 'replacement' 解码算法("iso-2022-cn" 或 "iso-2022-cn-ext" 两个值之一),则会抛出。

示例
const textDecoder1 = new TextDecoder("iso-8859-2");
const textDecoder2 = new TextDecoder();
const textDecoder3 = new TextDecoder("csiso2022kr", { fatal: true }); // Allows TypeError exception to be thrown.
const textDecoder4 = new TextDecoder("iso-2022-cn"); // Throw a RangeError exception.
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4