마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

HttpGet... 한글이 깨져나옵니다..

0 추천
 HttpGet httpGet = new HttpGet("http://maps.google.co.kr/maps/api/geocode/json?latlng="+x+","+y+"&sensor=true");
	    	        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();
	    	        }
	    	        
	    	    	JSONObject ret = jsonObject; 
	    	    	JSONObject location;
	    	    	String location_string;
	    	    	try {
	    	    	    location = ret.getJSONArray("results").getJSONObject(0);
	    	    	    location_string = location.getString("formatted_address");
	    	    	    Log.d("test", "formattted address:" + location_string);
	    	    	} catch (JSONException e1) {
	    	    	    e1.printStackTrace();

	    	    	}

 

 

 

 Log.d("test", "formattted address:" + location_string);

출력하면 알 수없는 문자열만 출력되요..

이정주 (780 포인트) 님이 2013년 5월 21일 질문

1개의 답변

0 추천
잘은 몰라도...

구글에서 넘어오는 문자 타입이 UTF-8로 알고 있습니다.

받으신 값을 JSONObject에 넣으시기 전에 UTF-8로

문자셋을 변경해주시면 될 것 같습니다.
비뢰광 (7,400 포인트) 님이 2013년 5월 21일 답변
...