# TextDecoder

文本解码器,将字节数据解码为字符串。每个实例使用创建时指定的编码。

# TextDecoder 兼容性 ?

Web微信小程序支付宝小程序AndroidiOSHarmonyOS
√xx4.314.714.71

# 构造函数

创建一个使用指定编码的 TextDecoder 实例。

名称 类型 必备 描述
label string 否 编码名称,支持 utf-8、gbk、gb2312,默认为 "utf-8"。不支持的编码按 "utf-8" 处理。

# TextDecoder 的属性值

名称 类型 必备 兼容性 描述
encoding string 是
只读属性 TextDecoder.encoding 返回一个字符串,其中包含了指定的解码器的解码算法的名称。

# TextDecoder 的方法

# decode(input : ArrayBuffer) : string;

TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。

# decode 兼容性 ?
Web微信小程序支付宝小程序AndroidiOSHarmonyOS
√xx4.314.714.71
# 参数
名称 类型 必填 描述
input ArrayBuffer 是 ArrayBuffer。
# 返回值
类型 描述
string 一个字符串。

# decode(input : DataView) : string;

TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。

# decode 兼容性 ?
Web微信小程序支付宝小程序AndroidiOSHarmonyOS
√xx4.31x4.71
# 参数
名称 类型 必填 描述
input DataView 是 DataView。
# 返回值
类型 描述
string 一个字符串。

# decode(input : Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array) : string;

TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。

# decode 兼容性 ?
Web微信小程序支付宝小程序AndroidiOSHarmonyOS
√xx4.314.714.71
# 参数
名称 类型 必填 兼容性 描述
input Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array 是
Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array 的实例
# 返回值
类型 描述
string 一个字符串。