English text and numbers are displayed in result string correctly, but other letters i wish to display are not. Instead of them there are a sequences of symbols like &-#-1080; ... I tried to set UTF-8 on my InputStreamReader, but it has no effect. Appreciate any help. Here's the code:
public class HttpClient {
private static String BASE_URL = "here url";
public String getData(String number) {
HttpURLConnection con = null ;
InputStream is = null;
try {
con = (HttpURLConnection) ( new URL(BASE_URL + number)).openConnection();
con.setRequestMethod("GET");
con.setDoInput(true);
con.setDoOutput(true);
con.connect();
// Let's read the response
StringBuffer buffer = new StringBuffer();
is = con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
String line = null;
while ( (line = br.readLine()) != null )
buffer.append(line + "\r\n");
is.close();
con.disconnect();
return buffer.toString();
}
catch(Throwable t) {
t.printStackTrace();
}
finally {
try { is.close(); } catch(Throwable t) {}
try { con.disconnect(); } catch(Throwable t) {}
}
return null;
}
}
------------
JSONObject jb = new JSONObject(data);
JSONArray jr = jb.getJSONArray("items");
JSONObject c = jr.getJSONObject(0);
String id = c.getString(TAG_ID);
String images = c.getString(TAG_IMAGES);
String title = new String(c.getString(TAG_TITLE).getBytes("ISO-8859-1"), "UTF- 8");//tried this - didn't help
String text = c.getString(TAG_TEXT);`