One part of my app performs a query (via php) on a mysql database. I use in the database UTF-8 because I have letters like é à ê that need to appear. I read through this problem because this seemed almost the same.
Android Java UTF-8 HttpClient Problem
However when I am implementing the code he replaces every return value with an é as null.
This is my code
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
params.setBooleanParameter("http.protocol.expect-continue", false);
HttpClient httpclient = new DefaultHttpClient(params);
HttpPost httppost = new HttpPost("http://www.example.com/example.php");
httppost.setEntity(new UrlEncodedFormEntity(query));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
String jsonText = EntityUtils.toString(entity, HTTP.UTF_8);
Toast.makeText(StoresInfo.this, jsonText, Toast.LENGTH_LONG).show();
is = entity.getContent();
So in the jsonText string he replaces return values with a "è" in it by null.
The last line is = entity.getConent(); I added this because I normally use the input stream to read it but this does not work as well.
Somebody has an idea?
This is my php code
<?php
mysql_select_db("database");
$q=mysql_query($_REQUEST['query']);
while($e=mysql_fetch_assoc($q))
$output[]=$e;
print(json_encode($output));
mysql_close();
?>