[thelist] PHP & UTF-8

Noah St. Amand noah at tookish.net
Tue Dec 20 14:55:37 CST 2005


Thanks Ivo and Kasmir.

Ivo P wrote (12/20/05 1:25 PM):
 > The first thing I would check is where the input $string is coming
 > from and the encoding at that source.

It's coming from a MySQL database. When I look at the table through 
phpMyAdmin, I indeed see "é" (rendered) where all the é 
should be. On the command line I see the é as expected.

One thing that may be relevant -- the collation throughout the database 
is "latin1_swedish_ci" -- I've tried to change it to "utf8_general_ci", 
but I have been unable to. This appears to be a common problem (I run 
the "alter" statement on the table and nothing happens). Do you think 
that this could be the cause of my problems?

Kasimir K wrote (12/20/05 1:34 PM):
> You could start by having a look at http://php.net/mbstring

I've been messing around with that stuff for a couple of days -- no luck 
so far.

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

utf8_decode changes the é to what looks to me like an inverted question 
mark (so who knows what character it might be).

I'm going to see if I can rebuild the database from scratch with the 
UTF8 collation. I'm open to any more ideas.

Thanks,
Noah



More information about the thelist mailing list