views:

192

answers:

6

My <title>The title</title> is based on my headline which can contain extended characters which I store as html entities &#xxx;

How can I easily turn these into real characters to make the browser window display them correctly or get them to appear correctly in their current form?

+1  A: 

http://www.php.net/manual/en/function.html-entity-decode.php

This functions seems to do the trick.

Brian Schroth
reko_t
+1  A: 

You can do this with html_entity_decode: http://www.php.net/html%5Fentity%5Fdecode

reko_t
+2  A: 

html_entity_decode()

http://www.php.net/manual/en/function.html-entity-decode.php

However, that a browser can't display entities in the title would be news to me. Are you sure there is no double encoding of some kind?

Pekka
A: 

Drupal is probably converting "&#8212;" special characters into their own entities (would be converted to &amp;#8212). You would have to tell drupal not to in that specific case, probably by specifying that your title already contains HTML entities and that you're aware of possible issues you could encounter without letting it converting the entities for you.

JP
A: 

The easiest way for you would be not to enter HTML into the title but rather use the correct characters to begin with.

Joey
A: 

html_entity_decode() is the way to go. Make sure to use as third parameter (see manual) the same character set your page uses and declare this character set inside your page HEAD with <meta http-equiv="content-type" content="text/html; charset=whatever-you-use"> BEFORE declaring the TITLE element (unless you can declare the charset in your HTTP headers).

djn