【问题标题】:Special Symbols not showing in webview特殊符号未在 webview 中显示
【发布时间】:2019-02-14 06:04:17
【问题描述】:

符号没有进入 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 字符?

【问题讨论】:

标签: android character-encoding android-webview


【解决方案1】:

试试

在 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");

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 2015-10-19
    • 2015-07-05
    • 2013-11-21
    相关资源
    最近更新 更多