开发者

How can I correctly display characters encoded like — in the browser within the title tag

My <title>The title</title> is based on my headline which can contain extended charact开发者_开发知识库ers 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?


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?


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

This functions seems to do the trick.


You can do this with html_entity_decode: http://www.php.net/html_entity_decode


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


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜