My database and tables are set to utf8_general_ci collation and utf8 charset. CodeIgniter is set to utf8. I’ve added meta tag charset=utf8, and I’m still getting something like: квартиры instead of cyrillic letters…
The same code running on the local machine works fine – Mac OSX. It’s only breaking in the production machine, which is Ubuntu 11.10 64bit in AWS EC2. Static content from the .php files show up correctly, only the data coming from the database are messed up. Example page: http://dev.uzlist.com/browse/cat/nkv
Any ideas why?
Thanks.
FYI:
When I do error_log() the data coming from the database, it’s the same values I’m seeing on the page. Hence, it’s not the browser-server issue. It’s something between mysql and php, since when I run SELECT * FROM categories, it shows the data in the right format. I’m using PHP CodeIgniter framework for database connection and query and as mentioned here, I have configured it to use utf8 connection and utf8_general_ci collation.
After 2 days of fighting this bug, finally figured out the issue. Thanks for @yourcommonsense, @robsquires, and a friend of mine from work for good resources that helped to debug the issue.
The issue was that at the time of the sql file dump to the database (import), charset for server, database, client, and connection was set to
latin1(statuscommand helped to figure that out). So the command line was set tolatin1as well, which is why it was showing the right characters, but the connection with the PHP code was UTF8 and it was trying to encode it again. Ended up with double encoding.Solution:
mysqldumpthe tables and the data (while inlatin1)/etc/my.cnfas Rob Squires mentionedAnd it works fine.
Thanks all for contribution!