如何解码 Android 的 WebView 中的符号 '?

How to decode symbol ' in Android's WebView?

我正在尝试在 WebView 中显示以下 html 代码:

<!DOCTYPE html><html><body> <p> c&#39;est la vie</p> </body>
</html>

符号 ' 被编码为 '

我调用这个方法加载的html是一个WebView:

webview.loadData(contentText, "text/html", null);

出于某种原因,WebView 显示:

c&

而不是:

c'est la vie

你知道怎么解决吗?

contentText 里面是什么?

    val content:String = "this is a test with ' in the text"
    wv.loadData(content, "text/html", null)

完美运行。

试试这个

String unencodedHtml = "<!DOCTYPE html><html><body> <p> c&#39;est la vie</p> </body></html>";
String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(),
    Base64.NO_PADDING);
myWebView.loadData(encodedHtml, "text/html", "base64");

有关详细信息,请阅读有关 Building web apps in WebView

的官方指南