我有这个 android 应用程序,我应该在其中向用户显示行车路线。 为此,我正在使用 Google Directions API。 这涉及向他们的 url 发出请求并在结果中获取 JSON。 现在,问题是:行车路线在标签/名称内 - “html-instructions”。 在这里我得到了指示,但它嵌入了 unicode 字符,例如。
"html_instructions": "在第一个\u003cb\u003eleft\u003c/b\u003e 驶向\u003cb\u003eBannerugatta Rd\u003c/b\u003e"
我如何摆脱这些 unicode 值并从中获取纯文本。
请帮忙
最佳答案
尝试这样的事情:
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) {}
关于java - 使用 Google Directions API 在 Android 应用程序中获取驾驶说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5935507/