2011-11-09 31 views
0

我有一個問題,即在我使用utf-8編碼時,英鎊符號在webview中被破壞。它顯示爲一些A ^(帽子在A之上)。 以下是我使用的代碼:Android的英鎊符號在webview中被破壞

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(); 
     } 

可能是什麼問題?

回答

1

我認爲這可能是一個設置問題,你是否設置了編碼?

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

查看文檔here

這可能是無關緊要的,但是,你總是可以(如果你的問題是特定於英鎊符號)在HTML中使用&pound;

+0

bhai bacha liya ...非常感謝。 – Maverick