Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htmlentities and é (e acute)

Tags:

People also ask

What is Echo HTML entities?

echo htmlentities($str, ENT_QUOTES, "UTF-8"); // Will only convert double quotes (not single quotes), and uses the character-set Western European. The HTML output of the code above will be (View Source): <! DOCTYPE html> <html>

What is HTML entities () function?

htmlentities() Function: The htmlentities() function is an inbuilt function in PHP that is used to transform all characters which are applicable to HTML entities. This function converts all characters that are applicable to HTML entities. Syntax: string htmlentities( $string, $flags, $encoding, $double_encode )

How do I display an accented character in HTML?

There are two methods. One is by using "HTML entities." You need to enter them as, for example, &eacute; . Here is a comprehensive reference of named entities; you can also reference the Unicode code point of a given character, using its decimal form as &#1234; or its hex form as &#x4D2; .

What is Htmlspecialchars?

Description. The htmlspecialchars() function is used to converts special characters ( e.g. & (ampersand), " (double quote), ' (single quote), < (less than), > (greater than)) to HTML entities ( i.e. & (ampersand) becomes &amp, ' (single quote) becomes &#039, < (less than) becomes &lt; (greater than) becomes &gt; ).


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 &#233; or &eacute;. 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?