
简体中文
只读属性 TextDecoder.encoding 返回一个字符串,其中包含了指定的解码器的解码算法的名称。
兼容性
uni-app x 兼容性
Web | Android | iOS | HarmonyOS | Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|---|---|---|---|
√ | 4.31 | x | x | 4.31 | x | - |
uni-app 兼容性
Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|
√ | x | - |
TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
input | ArrayBuffer | 是 | - | - | ArrayBuffer。 |
返回值
类型 |
---|
string |
UTS
var utf8decoder = new TextDecoder(); // default 'utf-8' or 'utf8'
var u8arr = Uint8Array.of(240, 160, 174, 183);
var i8arr = Int8Array.of(-16, -96, -82, -73);
console.log(utf8decoder.decode(u8arr)) // '𠮷'
console.log(utf8decoder.decode(i8arr)) // '𠮷'
utf8decoder = new TextDecoder("gbk"); // default 'utf-8' or 'utf8'
console.log(utf8decoder.decode(u8arr)) // '馉';
console.log(utf8decoder.decode(i8arr)) // '馉'
utf8decoder = new TextDecoder("utf-8");
var arraybuffer = new ArrayBuffer(4)
var dataView = new DataView(arraybuffer)
dataView.setInt8(0, -16)
dataView.setInt8(1, -96)
dataView.setInt8(2, -82)
dataView.setInt8(3, -73)
console.log(utf8decoder.decode(dataView)) // '𠮷';
兼容性
uni-app x 兼容性
Web | Android | iOS | HarmonyOS | Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|---|---|---|---|
√ | 4.31 | x | x | 4.31 | x | - |
uni-app 兼容性
Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|
√ | x | - |
TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
input | DataView | 是 | - | - | DataView。 |
返回值
类型 |
---|
string |
兼容性
uni-app x 兼容性
Web | Android | iOS | HarmonyOS | Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|---|---|---|---|
√ | 4.31 | x | x | 4.31 | x | - |
uni-app 兼容性
Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|
√ | x | - |
TextDecoder.decode() 方法返回一个字符串,其包含作为参数传递的缓冲区解码后的文本。
参数
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
input | TypedArray | 是 | - | - | Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array 的实例 |
返回值
类型 |
---|
string |
兼容性
uni-app x 兼容性
Web | Android | iOS | HarmonyOS | Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|---|---|---|---|
√ | 4.31 | x | x | 4.31 | x | - |
uni-app 兼容性
Android UTS 插件 | iOS UTS 插件 | HarmonyOS UTS 插件 |
---|---|---|
√ | x | - |