android - 特殊符号未在 webview 中显示
问题描述
符号没有进入 android WebView
有关更多信息,请参阅驱动器链接
https://drive.google.com/open?id=17PXFPJnVYkuGA_fkQPxskeIaw8AlzkcD
binding.tvQuestion.loadDataWithBaseURL("", questionlist.title, "text/html", "UTF-8", "");
binding.tvQuestion.getSettings().setJavaScriptEnabled(true);
如何显示特殊字符/unicode 字符?
解决方案
尝试
将 html 文件中的正确编码设置为元标记
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
Android 加载数据
webView.loadData("", "text/html; charset=utf-8", "UTF-8");
安卓设置
WebSettings webSettings = webView.getSettings();
webSettings.setDefaultTextEncodingName("utf-8");
webView.loadData("", "text/html; charset=utf-8", null);
如果您不可用,请替换特殊字符
mwebView.loadData(URLEncoder.encode(data, "utf-8").replaceAll("\\+"," "), "text/html", "utf-8");
推荐阅读
- excel - 特定 VBA 函数(例如 SendKeys)的潜在 Google 脚本等效项
- sql - 为什么我收到 TADOQuery 选择语句错误?
- sql - SQL 这个查询的另一种解决方案?
- python - 查找python打印功能
- c# - 将 DateTime 转换为月份数时出现 ASP.NET MVC ToString 错误
- c# - 如何每天像(1PM,2Pm,3Pm,4Pm,5Pm)每天5次调用AVplayer?
- android - 如何修复 Wordpress 应用程序在更新 5.2.1 后停止工作?
- javascript - 为什么 JS .focus() 只能在 50ms 或更长的 setTimeout 内工作
- javascript - 仅使用数组检查给定半径内的点
- asp.net - 如何在没有 JavaScript 或没有任何 JavaScript 表单的情况下更新字段