This is really driving me crazy. I’m building a spanish website (meaning a lot of latin characters) and I’m using Zend framework.
When I save a á it displays like á . I know is a charset encoding but I dont understand why.
My head charset is <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
My database is utf8_general_ci . I’ve changed the charset to others and always the same problem.
When I look in my database, what is saved is an á
Any idea why is this happening? Thanks!
Here goes the recipe to get rid of encoding headaches:
utf8_unicode_ci.metatag:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">If you have access to MySQL file configuration
my.cnfjust add this line:This tells MySQL to return results in UTF-8 for each connection.
If you cannot edit
my.cnfbut you are using PDO, open the connection this way:If you aren’t using PDO… start using it, what are you waiting for? Meanwhile you can execute this after each connection if you use ext/MySQLi:
Or this if you use plain old ext/MySQL: