我有一个问题,即当我使用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 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 & Advisory Services Limited are authorised and regulated by the <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();
}
可能是什么问题?
答案 0 :(得分:1)
我认为这可能是设置问题,您是否设置了编码?
WebSettings settings = myWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
请参阅文档here
这可能无关紧要但是,您可以随时(如果您的问题特定于英镑符号)在html中使用£
。