views:

198

answers:

2

At work, I'm beginning to have some issues with character encoding. I'd like to make our web app use UTF-8 all the way around. After a few hours of googling, I've only found a few sites with information on a UTF-8 LAMP setup. Does anyone know of any good resources online about UTF-8, Linux, Apache, MySql and PHP? I'll post what I've found in the answers.

+2  A: 

These are the links I have found so far.

docgnome
+2  A: 

Most of PHP is UTF-8 clean already, and Apache certainly is. Your weak link will be MySQL. You need to do three things to make MySQL UTF-8 clean.

  1. Always do a set names utf8 as the first thing you do after opening a connection.
  2. Configure all the various character encoding settings in my.cnf to be utf8 (look in the MySQL docs for which and how).
  3. Make sure your tables have utf8 collations.

Unless you tell it otherwise, MySQL will default to ISO 8859-15 (Western Eurpoean ASCII) with a Swedish sort order.

If you have to do conversions to and from UTF-8, then PHP can use the libiconv functions. However, faulty conversions will silently truncate the string.

staticsan