lundi 29 juin 2015

Database saving strange characters despite character set, and data sent, being in UTF8

When I save certain characters to my MariaDB database, they are being stored as a string of 2-4 characters.

For example, is saved in the database as â„¢.

From the head of the html page that contains the form I have

<meta charset="utf-8">

When I check the headers sent to the server, it shows

Content-Type:text/html; charset=UTF-8

The PHP file handling the form data has

$mysqli->set_charset('utf8');

I've converted the database and table to UTF8, by doing:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Checking the database and table details in information_schema table I can see that the database and table character set is UTF8 and default collation name is utf8_general_ci.

But the wrongly encoded characters are still being saved to the db.

I'm viewing the table data with terminal, so there should be no issue with the encoding on the viewing side.

What else am I missing?

Aucun commentaire :

Enregistrer un commentaire