2

I have a parser module in my application which will parse the response from a webservice and give the tag value. The tag value contains some special characters like ® etc. The problem is I could not decode the special characters to normal string. please find the sample response string below,

Apple® iPad™ Case

Please some body help me to solve this problem.

Mudassir
  • 13,031
  • 8
  • 59
  • 87
Rajapandian
  • 9,257
  • 24
  • 74
  • 86
  • Look at this post : http://stackoverflow.com/questions/5828091/decode-string-encoded-in-utf-8-format-in-android – Anass Aug 17 '11 at 07:46
  • 1
    @Rajapandian: Suggestion: If you want to use these special characters to show on screen only, then you can use them in a web page (in HTML), and then show that web page in web view. This way, those characters will be automatically rendered properly. – Mudassir Aug 17 '11 at 07:56
  • http://stackoverflow.com/a/4882425/1224741 – QED Jul 09 '13 at 16:31
  • possible duplicate of [Is there a faster way to decode html characters to a string than Html.fromHtml()?](http://stackoverflow.com/questions/4321896/is-there-a-faster-way-to-decode-html-characters-to-a-string-than-html-fromhtml) – QED Jul 09 '13 at 16:31
  • possible duplicate of [Java: How to decode HTML character entities in Java like HttpUtility.HtmlDecode?](http://stackoverflow.com/questions/994331/java-how-to-decode-html-character-entities-in-java-like-httputility-htmldecode) – Lukas Knuth Jul 10 '13 at 10:16

2 Answers2

6

Just Use String result = URLDecoder.decode(string, "UTF-8");

Or use this

byte[] data = Base64.decode(base64, Base64.DEFAULT);
String text = new String(data, "UTF-8");
vaava
  • 81
  • 2
  • 7
2

Use something like this

String decodedString = URLDecoder.decode(your string, "UTF-8");
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
blessanm86
  • 31,439
  • 14
  • 68
  • 79