[thelist] PHP & UTF-8

Kasimir K evolt at kasimir-k.fi
Tue Dec 20 12:34:05 CST 2005


Noah St. Amand scribeva in 2005-12-20 00:09:
> I'm trying to deal with UTF characters in PHP, and I'm running into some 
> bizarre problems. 

PHP & Unicode is not always without problems ;-) PHP uses single byte 
characters, so multibyte characters (like UTF-8 encoded Unicode) require 
some tricks.

You could start by having a look at http://php.net/mbstring

> strtr($string, "é", "e")
> becomes
> assurance_de_qualite?

> The é gets converted to "é".

And while é is included in ISO-8859-1 (which is what PHP uses by 
default) and Unicode maps one to one to ISO-8859-1, which should give 
you nice single byte UTF-8 characters, there probably is an application 
somewhere wanting to use combined characters for é.

There could be one really easy way (untested), how about trying:
strtr(utf8_decode($string), "é", "e")

.k



More information about the thelist mailing list