【发布时间】:2019-05-13 04:09:27
【问题描述】:
我正在尝试使用 REST API 从 Wordpress 网站创建新闻报道应用,但它以 UTF-8 编码。
我是 Dart 的新手,我只知道我可以仅通过字符数组而不是通过提供字符串(作为输入)来解码 Utf-8。那么如何为我的应用解码 Utf-8 中的字符串?
child: new Text(posts[index]["title"]['rendered'],
style: TextStyle(
fontSize: 21,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center),
),
new Padding(
padding: EdgeInsets.all(10.0),
child: new ListTile(
subtitle: new Text(posts[index]["excerpt"]
["rendered"]
.replaceAll(new RegExp(r'<[^>]*>'), '')),
),
),
【问题讨论】:
-
一般情况下,您可以使用
dart:convert的utf8.decode()函数将UTF-8编码的Uint8List解码为String。你说你已经有一个String,但你没有说你是怎么到达那个位置的。