If you want to convert your web application to unicode, that is easier than you might think. Just follow these steps:
-
Switch your character encoding to unicode. In Apache you can add the following line to your virtual host container or
.htaccessfile.AddDefaultCharset UTF-8
-
If you specified another encoding in your HTML files or used something like the
headermethod in PHP to force the server to send the pages with another encoding, you need to change those files, too. -
Backup your database. In MySQL you can do this by using
mysqldump.mysqldump -u username -p database table > table-yyyymmdd.sql
-
Convert the SQL dump to UTF-8 using something like
iconv.
Don’t overwrite your backup, but write the output oficonvto another file. This will save time if you need to go back to the old state or if something is messed up. Note: UTF-8 is not supported out of the box. Seeiconv -lfor a list of supported encodings.iconv -f ISO-8859-1 -t UTF-8 table-yyyymmdd.sql > table-yyyymmdd-utf8.sql
-
Replace the character encoding information in the converted SQL data. Again: Don’t mess with your backup – use the right file.
vi table-yyyymmdd-utf8.sql:%s/latin1_german2_ci/utf8_unicode_ci:%s/latin1/utf8
-
Replace your data in the database with the converted data. In MySQL this is a fast one:
mysql -u username -p database < table-yyyymmdd-utf8.sql
-
Check that everything works.
Done.
Shameless plug: If this post was useful to you, please consider buying yourself something from one of my Amazon stores: US store, UK store, FR store, DE store, CA store. If you're not into Amazon, why not donate something to GNOME, Mozilla or Wikipedia? Thank you!



didn’t we have another solution?