Page 1 of 1
MYSQL: Storing Foreign Characters ( chinese, arabic, etc )
Posted: Wed Feb 27, 2008 8:44 am
by mattkenefick
I have a table setup in MySQL to contain different copy versions of this page. It's collation is "utf8_general_ci" and the type is "text". Will this be able to store Chinese Simplified/Traditional, Arabic, etc characters?
Not necessarily for english view, but for their viewing. So if I was in China, wrote on the Chinese keyboard and stored it.. Then refreshed my screen, I'd be able to see it or would the Collation mess it all up?
Thanks a ton!
And this is very very urgent. Sorry

Re: MYSQL: Storing Foreign Characters ( chinese, arabic, etc )
Posted: Thu Mar 06, 2008 3:06 pm
by francisjeffy
Hi,
It will be stored in Unicode. Unicode is a set of numbers. For example every character in Chinese language will be represented using a unique number. So the text you enter in Chinese will be stored in MySql as a series of these Unicode representation of the text.
Hope that helps,
JeF.
Re: MYSQL: Storing Foreign Characters ( chinese, arabic, etc )
Posted: Fri Mar 07, 2008 6:02 am
by batfastad
To make sure your PHP/MySQL solution is fully working with UTF-8 and Unicode, follow this excellent tutorial to make sure that everything is set up as it should be
http://www.nicknettleton.com/zine/php/p ... cheatsheet
But one extra thing that isn't mentioned in that text (but is buried down in the comments) is that you should also add a line immediately after you connect to MySQL.
So this:
Code: Select all
// CONNECT TO SQL
mysql_connect($sql_server, $sql_user, $sql_pass);
@mysql_select_db($sql_db) or die('Unable to select database');
Becomes this:
Code: Select all
// CONNECT TO SQL
mysql_connect($sql_server, $sql_user, $sql_pass);
@mysql_select_db($sql_db) or die('Unable to select database');
mysql_query("SET NAMES 'utf8'");
So just add that 4th line every time you connect to MySQL.
Hope this helps, B