htmlentities() giving strange results...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abeall
Forum Commoner
Posts: 41
Joined: Sun Feb 04, 2007 11:53 pm

htmlentities() giving strange results...

Post by abeall »

I'm trying to use the htmlentities() function but finding that many characters get very strange results. For instance, the character « does not get converted to simply «, but rather «. Some characters after conversion are even worse -- for instance, the character comes out as â�¹. What's wrong?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I would suspect the data you have stored is not simple ascii, but some variant of unicode or other multibyte character set. htmlentities() was built for the ASCII character set.
abeall
Forum Commoner
Posts: 41
Joined: Sun Feb 04, 2007 11:53 pm

Post by abeall »

Right on, thanks mate. Changing the third parameter to "UTF-8" has done the trick. Cheers!
Post Reply