MySQL and UTF-8 the Right Way
When saving data in languages other than English, the character encoding to use is UTF-8. The major advantage of this is that it supports thousands of different characters, allowing you to save an å as an å in the database "for real" – which makes working with text significantly easier.
Unfortunately, it is quite common to encounter problems when attempting to save UTF-8 encoded text in a MySQL database, even when both the database and table have the correct encoding and collation. The most likely cause of this is that MySQL's connection character set is set to latin1 by default instead of UTF-8. This leads to issues with Swedish and other characters that are not included in the latin1 set... Here’s a solution to the problem that has worked for us.
If You Administer the Database Yourself
If you have access to the my.conf file, you can add the following two lines under the [mysqld] section:
collation_server=utf8_unicode_ci
character_set_server=utf8
to permanently resolve the issue on that server.
If You Use a Web Hosting Service
However, if you are using a web hosting service, you need to set the NAMES variable to the correct value. You do this in the code after connecting to the database. Here’s how it looks in PHP:
mysql_query("SET NAMES utf8");
or use the following line to ensure that the collation is also set to the correct values:
mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
… and you may even need to set the character set manually if it is not set to UTF-8:
mysql_query("SET CHARACTER_SET utf8");
If MySQL is configured correctly, the first line above should suffice, but it might not hurt to set all of them just to be on the safe side...
If you want more information about this, you can find it in the MySQL 5.0 Reference Manual, section 9.1.4.