文字列から「ö」のような特殊文字を置き換えて、適切な文字「Ö」を付けるにはどうすればよいですか?

user2940365

ねえ、私は逆のGoogleジオコーダーを使用します。たとえば、都市名が「Königsaich」の場合、ジオコーダーは「Königsaich」という名前を付けます。「ö」文字をフィルタリングして、正しい文字「ö」に置き換えるにはどうすればよいですか?

編集:

私のコード:

public JSONObject getJSONCity(double lat, double lon){

         HttpGet httpGet = new HttpGet("http://maps.google.com/maps/api/geocode/json?latlng="+lat+","+lon+"&sensor=false");
            HttpClient client = new DefaultHttpClient();
            HttpResponse response;
            StringBuilder stringBuilder = new StringBuilder();

            try {
                response = client.execute(httpGet);
                HttpEntity entity = response.getEntity();
                InputStream stream = entity.getContent();
                int b;
                while ((b = stream.read()) != -1) {
                    stringBuilder.append((char) b);
                }
            } catch (ClientProtocolException e) {
                } catch (IOException e) {
            }

            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject = new JSONObject(stringBuilder.toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            return jsonObject;
    }


    public String getCityname(double lat, double lon){

        JSONObject ret = getJSONCity(lat,lon); 
         JSONArray jsonArray;

         JSONObject location;
         String location_string;

         try {
             jsonArray = ret.getJSONArray("results").getJSONObject(0).getJSONArray("address_components");
             cityname = jsonArray.getJSONObject(2).getString("long_name");

             //Get JSON Array called "results" and then get the 0th complete object as JSON        
             location = ret.getJSONArray("results").getJSONObject(0); 
             // Get the value of the attribute whose name is "formatted_string"
             location_string = location.getString("formatted_address");

             System.out.println(" results: " + location_string);

             System.out.println(" My City: " + cityname);
         } catch (JSONException e1) {
             e1.printStackTrace();
         }
         return cityname;
    }

誰かが私に例を挙げてもらえますか?

バヌシャルマ
String actualstring ="what ever your string which you want to replace here get ";
         if(actualstring.contains("here your string which u want to chk"));
                { 
                   // it chk weather it contain that string which u want to replace 
           actualstring.replace("target", "replacement");
                 }

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ