WebView 的 loadData 编码问题 [英] Encoding issue with WebView's loadData
本文介绍了WebView 的 loadData 编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
String uri = Uri.encode(html);
webview.loadData(uri, "text/html", "ISO-8859-1");
显示时,latin1 字符被奇怪的字符替换.
When displayed, the latin1 characters are replaced by weird characters.
如果我直接在 TextView 中加载 html(只是为了测试),拉丁字符会正确显示.
If I load the html directly in a TextView (just to test), latin characters are properly displayed.
有人可以帮忙吗?
谢谢
html:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- some html -->
</html>
推荐答案
让它工作的唯一方法,如评论 此处:
Only way to have it working, as commented here:
webview.loadDataWithBaseURL("fake://not/needed", html, "text/html", "utf-8", "");
没有 URI 编码,utf-8...loadData 错误?
No URI encoding, utf-8... loadData bug?
这篇关于WebView 的 loadData 编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文