I'm trying to store strings that may include special characters. Presuming the gurus under the hood here have it working, I'd like to be able to store and retrieve characters similar to the following:
© ɤ ë ¾ ñ
My meta tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
...doesn't specify which UTF-8 collation to use, so I left it as default "utf8_general_ci"....but I'm getting random odd characters.
I figure it's got to be one of the 3 below -- and I've tried them all on the table, but wondered if maybe that corrupted the data by switching it with data already inside. (No worries, its just filler data for dev purposes.)
Which collation should I use to not have problems with those types of characters?
Thanks for your wisdom!
Hmm... running this query against the database (SHOW VARIABLES LIKE 'character_set%') I find the following:
Another post suggested to use mysql_query("SET NAMES 'utf8'"); and that it solved the problem. That's cool and I'll give it a try -- and if it works for me, is there a way to achieve it through phpMyAdmin?
It's best to use mysql_set_charset() rather then mysql_query("SET NAMES 'utf8'") to set the default charset for the connection to the database. It should be used after you established the connection to the database but before you start running any queries against the database
Thank you -- if you don't mind a follow-up: Are there certain benefits to using utf8_general_ci over utf8_unicode_ci (or vice versa) for the database encoding?