Alex Rivera | Logout

htmlentities and é (e acute)

Asked 2011-10-05T15:26:11.360
10

I'm having a problem with PHP's htmlentities and the é character. I know it's some sort of encoding issue I'm just overlooking, so hopefully someone can see what I'm doing wrong.

Running a straight htmlentities("é") does not return the correct code as expected (either é or é. I've tried forced the charset to be 'UTF-8' (using the charset parameter of htmlentities) but the same thing.

The ultimate goal is to have this character sent in an HTML email encoded in 'ISO-8859-1'. When I try to force it into that encoding, same issue. In the source of the email, you see é, and in the HTML view é.

Who can shed some light on my mistake?

Edit
Report

1 Answer

2

I suggest you take a look at http://php.net/html_entity_decode . You can use this in the following way:

$eacute = html_entity_decode('é',ENT_COMPAT,'iso-8859-1');

This way you don't have to care about the encoding of the php file. edit: typo

answered 2011-10-05T15:30:51.093

Your Answer