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.
- The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
- PHP UTF-8 cheatsheet
- Converting Web Applications to UTF-8 (Though this seems to be unreachable at the moment)
docgnome
2008-10-24 01:13:43
+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.
- Always do a
set names utf8
as the first thing you do after opening a connection. - Configure all the various character encoding settings in my.cnf to be utf8 (look in the MySQL docs for which and how).
- 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
2008-10-28 01:22:00