Parsing UTF-8 encoded content correctly from SQL through Php with Json


SDK Version: 
M3

To get this thing working, just follow these steps:

1. First thing to do is changing the default character set of your SQL database and its tables to UTF-8.

2. Your Php file should look something like this:

  1.   $connection = mysql_connect("server_ip_address", "user", "password");
  2.  
  3.   if (!$connection) die("Couldn't connect to server");
  4.   mysql_select_db("database_name", $connection) or die("Could'nt select the database!");
  5.  
  6.   // This is very IMPORTANT!!!
  7.   mysql_query("SET NAMES 'UTF8'");  
  8.  
  9.   $sth = mysql_query($query);
  10.   $rows = array();
  11.   while($r = mysql_fetch_assoc($sth)) {
  12.       $rows[] = $r;
  13.   }
  14.   print json_encode($rows);
  15.  
  16.   mysql_close($connection);  
  17. }

3. Now you can parse these json forrmatted strings, to your application. Here's how:
http://www.helloandroid.com/tutorials/connecting-mysql-database