3

I have this android app where I am supposed to show the driving directions to the users. I am using Google Directions API for this. This involves making request to their url and getting the JSON in result. Now, the problem is : the driving directions are inside the TAG/Name - "html-instructions". Here I get the directions, but it's embedded with unicode characters for eg.

"html_instructions": "Take the 1st \u003cb\u003eleft\u003c/b\u003e toward \u003cb\u003eBannerugatta Rd\u003c/b\u003e"

How do I get rid of these unicode values and get the plain text out of it.

Please help

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Ankit
  • 289
  • 2
  • 6
  • 13

2 Answers2

0

direcObject.getString("html_instructions").replaceAll("\<.*?>","") works for getting html instruction without tag

0

Try something like this:

try {
    // Convert from Unicode to UTF-8
    String string = "abc\u5639\u563b";
    byte[] utf8 = string.getBytes("UTF-8");

    // Convert from UTF-8 to Unicode
    string = new String(utf8, "UTF-8");

} catch (UnsupportedEncodingException e) {}
Mark Mooibroek
  • 7,636
  • 3
  • 32
  • 53
  • 2
    thanks for answering. Actually in actual text that I got after parsing had HTML tags which I removed using replaceAll("\\<.*?>",""). But Still thanks for concern – Ankit May 09 '11 at 13:21
  • You answer didn't work for me. The `replaceAll("\\<.*?>","")` of @Ankit, yes. – 4gus71n Oct 29 '13 at 16:01