I have a MySQL DB, encoded in UTF8, where some records have ‘ā’s in them (in case it doesn’t show up right in SO, that’s an ‘a’ with a line above it).
There is a PHP script that is getting the records, putting them in an array, and json_encoding them. No matter whether the script is being invoked by ajax or the webpage, the ‘ā’s show up as question marks. Where is the problem, and how do I fix it?
Thanks,
Jamie McClymont
EDIT: Forgot to mention that the ‘ā’s show up fine in PHPMyAdmin
For the text to print correctly you need to set the charset of the mysql connection and the page
For the connection the following query will work
Run this query right after connecting
If the charset is still incorrect try adding
assuming you’re outputting json
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html