google-cloud-firestore - 特殊字符在 Firestore 字符串中不起作用
问题描述
我正在尝试将一些数据从网站提取到我的 Firebase Firestore 数据库,但我遇到了一个小问题,即特殊字符被转换为奇怪的字符,例如这句话“他擅长 - 找人”。换算成“他擅长——找人”这个词,我是不是要逃避那些角色还是什么?
代码:
String url =
'some-url';
var response = await http.get(url);
String body = response.body;
List results = jsonDecode(body)['results'];
await firestore
.collection('games')
.document(results[i]['id'].toString())
.setData({
'description': results[i]['description']});
解决方案
只是使用 utf8 来解码结果字符串,
utf8.decode(results[i]['description'].toString().runes.toList());
感谢帮助。
推荐阅读
- c# - 我只在视图模型类中获得组合框选定项,但不能在视图模型类之外使用它,它的抛出为空
- prolog - Prolog 压缩与合并排序
- api - 我是否应该假设 API 总是返回其文档所说的内容?
- scala - 用于递归泛型定义的 Scala 通配符
- svelte - 如果数据不存在或已经使用 Svelte / Sapper 获取了 svelte 类型的 store id 数据,如何有效地从 rest api 获取数据
- intellij-idea - Intellij 2020.1.2:为什么暂存文件给出不同的输出?
- c# - WPF ListView - 选择刚刚添加到项目源的项目
- javascript - Angular Web Components - @Input 没有收到值
- javascript - Javascript - 日期格式
- html - 如何在 Bootstrap 4 中圆化卡片(正文和图像)的角?