使用 convert 包下的 utf8 对象的 decode 方法。
下面代码假设bytes为 Uint8List 类型的对象,则代码如下:
import 'dart:convert';
void main(){
Uint8List bytes = ......; // 此处省略
String str = utf8.decode(bytes);
print(str);
}
这里变量 utf8 为dart:convert包下的 Utf8Codec 类型的实例。
使用 convert 包下的 utf8 对象的 decode 方法。
下面代码假设bytes为 Uint8List 类型的对象,则代码如下:
import 'dart:convert';
void main(){
Uint8List bytes = ......; // 此处省略
String str = utf8.decode(bytes);
print(str);
}
这里变量 utf8 为dart:convert包下的 Utf8Codec 类型的实例。
本文标题:Uint8List使用字符集utf8转为String
本文链接:https://www.haomeiwen.com/subject/ctekoltx.html
网友评论