Reputation: 12382
I want to retrieve some data from a MySQL database in a JSON format.
My tables have the collation set to utf8_general_ci
. And In my PHP code I have this code:
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
printf("Current character set: %s\n", $mysqli->character_set_name());
}
But when the page is retrieved by the browser, words with accents aren't shown properly. For instance, a "á" is presented as "\u00e1".
What am I missing here?
Upvotes: 1
Views: 484
Reputation: 2204
HTML: <meta charset="utf-8" />
Info: http://www.joelonsoftware.com/articles/Unicode.html
Upvotes: 0
Reputation: 140234
You are simply looking at encoded JSON, there isn't a real problem. When you decode the JSON, you will get á
again.
$a = json_encode( 'á' );
echo $a; //'"\u00e1"'
echon json_decode( $a ); // 'á'
Upvotes: 2