我需要从 URL 获取一个 json 文件,解析它并获取内容。此 Json 包含克罗地亚语字符和符号,例如“Pošaljite e-marlon”。我使用以下代码从 URL 获取 Json 文件。这是我使用的 URL http://ptracker.com/webteh/localization.php
InputStream is = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(language_url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String json = null;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is, Charset.forName("ISO-8859-2")), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
Log.v("json >>", json);
} catch (Exception e) {
Log.e("Buffer Error",
"Error converting result " + e.toString());
}
响应 json 不显示原始字符串“Pošaljite e-marlon”。它给出“Poaljite e-mailom”。如何解决这个问题?