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」を提供します。これを修正する方法は?