I have a MySQL database, in wich i have a table with a column whith a collation of:
utf8_general_ci
In this column i am saving special characters like:
á, é, í, ó, ú, ñ
When i get this column using PHP and print them in a web page, everything looks perfect, the problem comes when i print those chracters on my android app, it looks like this:
ñ
And wierd characters like that.
I have tried to solve this using:
mysql_query("set names 'utf8'");
But i havent luck. How can i solve this? At first i think it was a MySQL problem, but i can see that that the data is printed correct when its on a web page, so maybe its android...
I have the next code in android:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(Utils.IP_ADDRESS + "index.php?module=fetchImage&page=main&ajax=1");
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(1);
nameValuePair.add(new BasicNameValuePair("sessionId", prefs.getString("sessionId", null)));
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
HttpResponse response = httpClient.execute(httpPost);
responseBody = EntityUtils.toString(response.getEntity());
System.out.println(responseBody); // here i get Otoño and it should be Otoño