问题
I'm building an PHP5 application with MySQL for English and Spanish speaking. Should I set the character set and collation to UTF8 and then convert everything into the database with mbstring? Or, should I use some kind of latin character set that supports both English and Spanish? The application is strictly US only and it doesn't need to support the full international range of languages.
I'm using CodeIgniter on most projects. I just noticed the CI Database settings.
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
So, I assume these two settings should be good. I assume I need to reset the MySQL database char set and any collation settings on the db and tables?
回答1:
Set the charset to UTF8 both in php and in the database.
Use collation utf8_latin_ci
in all tables in the database.
See: http://dev.mysql.com/doc/refman/5.5/en/charset-general.html
回答2:
I speak portuguese, so I use utf8_general_ci
for database, charset=UTF-8
in my html headers and I run a series of commands in my Connection class when it opens the link to force utf8 collation in the communication. This won't affect performance in a noticeble way so you can simply use it regardless of what language you are using.
来源:https://stackoverflow.com/questions/7894582/what-mysql-collation-character-set-should-i-use-for-english-and-spanish