CHARSET Issues.... htmlentities()

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
jeffereylockyer
Forum Newbie
Posts: 1
Joined: Tue Aug 02, 2005 6:16 pm

CHARSET Issues.... htmlentities()

Post by jeffereylockyer »

Here is the problem I am having. I am trying to take data that was placed in my database with unicode characters, such as é å ø etc.... The database I am dealing with is in unicode format. Here is the php code I am trying to test...

Code: Select all

<?php
$str = "A 'quote' is <b>bold</b> é";
echo $str;
$str2 = htmlentities($str, ENT_QUOTES, "UTF-8");
echo $str2;
?>
Here is what I get in return
A 'quote' is bold Ž
A 'quote' is <b>bold</b> Ž

This is the source of the html page produced by php
A 'quote' is <b>bold</b> Ž
A 'quote' is <b>bold</b> Ž

What I assume I should be getting is

A 'quote' is bold é
A 'quote' is <b>bold</b> é

It also does not seem to matter which encoding scheme I pass to htmlentities (UTF-8, ISO-8859-1, ISO-8859-15, etc...) they all return the same value as above. I am not sure if this is affected by something on the server side or the php method, or the browser ? I really hope someone can shed some light on this issue for me, thanks in advance.

Jeff.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Im getting :

A 'quote' is bold é
A 'quote' is <b>bold</b> é

in both FireFox 1.0.6 and IE 6.0 SP1
Post Reply