안녕하세요 저는 역방향 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;
}
사람이 나에게 예를 들어 주실 수 있습니까?
에있다 - 일반적으로는 "바이트를 가지고 어디에 텍스트 변환 ". Geocoder API를 사용하는 방법을 알려주세요. –
러시아 이름이 잘못 나오는 동안 오류가 발생했다고 생각하십니까? –
나는 정규 표현식 개념을 적용 할 수 있다고 생각합니다. –