Which string variables in mysql support utf-8?

Posted on

Question :

I have a table that stores string from a user and is displayed in a web form.
But as I see when the user inputs e.g. in a language of cyrilic alphabet (I assume is UTF-8) garbage are displayed back.
I did a show create table and I saw that the table is defined as LATIN-1 and the column that stores the string is defined as TEXT.
I am not clear on what type of data does TEXT stores. Is it only for ASCII? Should I be using a different data type? Which would be the most appropriate?

Answer :

You’ll have to specify a character set of UTF8 on the table schema. See http://dev.mysql.com/doc/refman/5.5/en/charset-syntax.html

Depending on your needs you can specify table defaults which then apply to all unspecified text columns (char/varchar/text) or you can specify on a per column level.

You’ll also need to have your applications to specify a UTF-8 character encoding. The specifics on how to do this will depend on the language you are using.

Leave a Reply

Your email address will not be published. Required fields are marked *