0

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

4

3 に答える 3

0

ISO_8859-2はスペイン語記号をサポートしていないため、Charset UTF-8 を使用してみてください。

于 2013-07-10T15:44:34.117 に答える