cranjled — 2011-06-01T14:48:56-04:00 — #1
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!
cranjled — 2011-06-01T15:05:29-04:00 — #2
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?
spacephoenix — 2011-06-02T02:32:20-04:00 — #3
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
cranjled — 2011-06-02T12:35:14-04:00 — #4
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?