Friday, September 17, 2010

Finding the encoding of a MySQL table

Inside a MySQL database, you can type the following:

sql> show variables like "character_set%"
    -> ;
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | utf8                       | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | latin1                     | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

Thanks to https://wincent.com/wiki/Finding_out_the_encoding_of_a_MySQL_database

http://blog.awarelabs.com/2008/django-tips-utf-8-ascii-encoding-errors-urllib2-and-mysql/

Django uses a default character set of UTF-8, so when it connects to the MySQL database, it uses UTF-8. If you use mysql to interface, you will notice that the character_set_results are set to latin1 (otherwise known as ASCII).

No comments:

Post a Comment