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?
You are simply looking at encoded JSON, there isn’t a real problem. When you decode the JSON, you will get
áagain.