I recently shifted from mysqli standard to PDO in PHP. My database is written with Workbench and accessible from a remote server, handled with cPanel (phpMydamin). All my tables are in utf8_general_ci. In PHP, I use the slim library as well. I tried to handle ut8 as follow, in a ManagerDAO.class.php file calling spyc.php:
protected function __construct() {
$this->setUpPDO();
}
private function setUpPDO() {
$settings = spyc_load_file(self::SETTINGSFILE);
$this->pdo = new PDO("mysql:host=" . $settings['Host'] . ";dbname=" . $settings['DBName'].";charset=UTF8", $settings['Username'], strval($settings['Password']));
$this->pdo->exec("SET CHARACTER SET utf8");
$this->pdo->query("SET NAMES 'utf-8'");
}
In the index.php file I wrote:
header('Content-Type: application/json; charset=UTF-8');
ini_set( 'default_charset', 'UTF-8' );
As a result, instead of "日本語" I have "\u65e5\u672c\u8a9e" and instead of "Français" I have "Fran\u00e7ais". What is the way to solve this issue? Thank you in advance.
Edit:
After several check, we eventually looked at what we see in the android phone screen, and the words (or kanji for Japanese) are properly written. The /u enconding for none ASCII character is only in the url allowing data access from the database to the mobile app. I don't have a clue why it's encoded that way here, but it doesn't really matter as long as it's encoded properly on the smartphone.