I am developing an app that will display text in three languages. I am getting data from server via PHP scripts. The problem is that arabic and kurdish text shows up as ? marks. I have modified the code to accept utf-8 characters. The data shows up as ? marks even when opened in browser. The collation of the mysql server is utf8. Also I have added kurdish and arabic text statically to my app and it works perfectly. I have also tried utf8_encode() without any results -
public static String executeHttpGet(String url) throws Exception {
BufferedReader in = null;
try {
HttpClient client = getHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
// in = new BufferedReader(new InputStreamReader(response.getEntity()
// .getContent()));
in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent(), "UTF-8"));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String result = sb.toString();
return result;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e("log_tag", "Error converting result " + e.toString());
e.printStackTrace();
}
}
}
}
Is there something wrong in my code? Or do I need to do something else? Thanks in advance.
EDIT: I am using the following php script to encode json data -
$subcat_id = mysql_real_escape_string(intval($_GET["id"]));
$query = mysql_query("select * from subcategory where category_id = $subcat_id")or die(mysql_error());
while($row = mysql_fetch_assoc($query))
$output[]=$row;
print(json_encode($output));
and the collation used on the mysql server is utf8. Thanks again.