Richtige Verwendung von UTF-8 Zeichensätzen mit PHP und MySQL

0 Stimmen

PHP and MySQL don’t just work with UTF-8. In particular, the client connection from PHP to MySQL defaults to latin1. There don’t seem to be any PHP settings to change this. On the MySQL side there are ‘default-character-set’ settings you can put in various sections of the my.cnf, but for me they didn’t seem to help.I found two ways to solve the problem. The first is to issue a mysql_query("SET NAMES 'utf8') immediately after every mysql_connect to manually switch the connection to utf8. That’s a huge pain if you have a lot of code (even in my mini 5-file test-case I forgot one instance at first).

http://www.papascott.de/archives/2007/05/05/corrupted-utf-8-characters-w...