【问题标题】:android pound symbol is corrupted in webviewwebview中的android磅符号已损坏
【发布时间】:2011-12-25 05:42:57
【问题描述】:

我有一个问题,即使我使用的是 utf-8 编码,webview 中的磅符号也会损坏。它显示为一些 A^£(上限在 A 的顶部)。 这是我正在使用的代码:

aboutustext = (WebView) findViewById(R.id.aboutustext);
    String text = "<div style='color:#878787; padding:5px 5px 5px 5px;'><p>Rathbone Brothers Plc, through its subsidiaries, is one of the UKs leading providers of investment management services for private clients, charities and professional advisers.</p>";
    text += "<p>Key facts about Rathbone Brothers Plc:</p>";
    text += "<ul><li>FTSE 250 listed company </li>";
    text += "<li><a href='http://www.rathbonesra2010.com' target='_blank'>Online 2010&nbsp;report and accounts</a></li>";
    text += "<li>A heritage dating back to 1742</li><li>11 offices across the UK with an offshore presence in Jersey</li>";
    text += "<li>170 experienced investment professionals</li><li>£16.36 billion of funds under management* </li><li>Over 35,000 clients</li>";
    text += "<li>Rathbone Investment Management Limited and Rathbone Pension&nbsp;&amp; Advisory Services Limited are authorised and regulated by the&nbsp;<a href='http://www.fsa.gov.uk/'>Financial Services Authority</a></li>";
    text += "</ul><p>Our success and reputation is built on the simple, but increasingly rare, commitment to superior client service as well as state-of-the-art administrative systems. We have no ties to banks or large financial institutions, giving you a whole-of-market and objective perspective on your investments. This, together with direct access to you investment manager, results in an investment portfolio that will meet your requirements.</p>";
    text += "<p>If you would like to know more about the funds which we offer, please visit the <a title='Rathbone Unit trust Management Website' href='http://www.rutm.com/' target='_blank'>Rathbone Unit Trust Management </a></p>";
        text += "<p>* Funds under management as of 30 June 2011</p></div>";

        try {
            aboutustext.loadData(URLEncoder.encode(text,"utf-8").replaceAll("\\+"," "),
                    "text/html", "utf-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

可能是什么问题?

【问题讨论】:

    标签: android utf-8 webview android-webview url-encoding


    【解决方案1】:

    我认为这可能是设置问题,您是否设置了编码?

     WebSettings settings = myWebView.getSettings();
     settings.setDefaultTextEncodingName("utf-8");
    

    参见文档here

    这可能无关紧要,但是,您总是可以(如果您的问题是特定于磅符号)在 html 中使用 &amp;pound;

    【讨论】:

      猜你喜欢
      • 2013-03-09
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      • 2012-05-22
      相关资源
      最近更新 更多