【问题标题】:Webview doesn't show some charactersWebview 不显示某些字符
【发布时间】:2012-11-16 02:37:56
【问题描述】:

我有一个带有文本转录的 utf-8 html 页面(在 HTML 中有正确的字符集)。转录中的某些字符显示为空方块。我尝试使用 loadDataWithBaseUrl 和一个简单的 loadData 进行加载。它似乎适用于 4.1,但不适用于 3.0。可能是字体问题?

【问题讨论】:

    标签: android webview


    【解决方案1】:

    你是这样加载内容的吗?

    String contents = res.getString(R.string.content_details);
    WebView wv1 = (WebView)findViewById(R.id.webView1);
    wv1.loadDataWithBaseURL("file:///android_asset/", contents, "text/html", "utf-8", null);
    

    这对我有用。

    【讨论】:

    • 您能发布 html 的内容,以便我可以尝试加载它吗?曾经发生在我身上的事情是,当我在 Mac 上使用 Eclipse 时。工作区的编码默认为MacRoman;我把它改回 UTF-8,它解决了这个问题。
    猜你喜欢
    • 2014-05-19
    • 2015-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-21
    • 2011-08-31
    • 1970-01-01
    • 2017-01-06
    相关资源
    最近更新 更多