[英]Android - unicode characters aren't displayed correctly
I'm trying to load local html file: 我正在尝试加载本地html文件:
WebView webView = (WebView)findViewById(R.id.webView1);
webView.getSettings().setDefaultTextEncodingName("utf-8");
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("file:///android_asset/www/index.html");
index.html contains this: index.html包含以下内容:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head >
<body>
რაღაც ტექსტი
</body>
</html>
but it doesn't work. 但这不起作用。 Can anyone help? 有人可以帮忙吗? PS that text is in Georgian PS文本为格鲁吉亚语
Edit: I've tried loading that text using almost every possible method I've found - loadDataWithBaseURL and loadData methods didn't work either. 编辑:我已经尝试使用几乎所有可能的方法加载该文本-loadDataWithBaseURL和loadData方法也不起作用。
Closed: Here is the problem: That version of Android didn't recognize Georgian characters. 已关闭:这是问题所在:该版本的Android无法识别格鲁吉亚字符。
You can use this approach; 您可以使用这种方法。
String start = "<html><head><meta http-equiv='Content-Type' content='text/html' charset='UTF-8' /></head><body>";
String end = "</body></html>";
webView.loadData(start + YOURCONTENT + end,"text/html; charset=UTF-8", null);
Ensure that your file is actually encoded as UTF-8. 确保您的文件实际编码为UTF-8。
Check if your editor save it as UTF-8. 检查您的编辑器是否将其另存为UTF-8。 It could be the problem. 可能是问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.