Maverick
Maverick

Reputation: 2760

android pound symbol is corrupted in webview

I have a problem where the pound symbol is getting corrupted in the webview, even though when i am using utf-8 encoding. Its getting displayed as some A^£ (the cap is on top of A). Here is the code iam using:

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

What could be the problem?

Upvotes: 0

Views: 985

Answers (1)

abhinav
abhinav

Reputation: 3217

I think it could be a settings issue, did you set the encoding?

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

See documentation here

This might be irrelevant but, You could always(if your problem is specific to the pound symbol) use &pound; in the html.

Upvotes: 1

Related Questions