我正在尝试将来自 api 的正确阿拉伯语/波斯语单词显示到我的Text(). 就英语而言,它表现得很好,但随着语言的变化,它会返回类似 LATIN1 的内容。
我已经按照这个问题来纠正我的问题:InvalidrabiccharlesWithUtf-8charsetRetrived withhttp.getFlutter\n
\n\n我有一个name来自 API 的字符串。它的酒吧名称为:Bar Beirut - \xd8\xa8\xd8\xa7\xd8\xb1 \xd8\xa8\xd9\x8a\xd8\xb1\xd9\x88\xd8\xaa。但在回复中,我得到了上面的屏幕截图。
我尝试先对字符串进行编码,然后对其进行解码,但没有成功。
\n\nvar encoded = utf8.encode(data[\'name\']);\nthis.name = utf8.decode(encoded);\nRun Code Online (Sandbox Code Playgroud)\n\n所以我this.name在我的 中使用Text(),但它显示英语字符,而对于阿拉伯语,它显示 LATIN1。任何帮助,将不胜感激。谢谢
尝试以下操作,它对我来说适用于阿拉伯字符
return http.get(Uri.encodeFull(baseUrl), headers: {
"Content-Type": "application/json",
}).then((response) {
return json.decode(utf8.decode(response.bodyBytes));
});
Run Code Online (Sandbox Code Playgroud)