解码html实体问题

时间:2010-03-03 12:37:20

标签: php character-encoding

我需要显示以下文本行

<ul><li>Complementary to cleansing with HY-ÖL®<li>Especially for irritated and sensitive skin<li>Noticeably calms and relaxes the skin</ul>

如果我执行以下操作

html_entity_decode('<ul><li>Complementary to cleansing with HY-ÖL®<li>Especially for irritated and sensitive skin<li>Noticeably calms and relaxes the skin</ul>');

文字以下列方式出现

* Complementary to cleansing with HY-�L�
* Especially for irritated and sensitive skin
* Noticeably calms and relaxes the skin

问题在于它试图对HY-ÖL®进行编码,然后它就像这样的HY- L

在这里感到困惑,请帮忙

3 个答案:

答案 0 :(得分:4)

您需要在以下位置指定要输出的字符编码:

html_entity_decode('…', ENT_COMPAT, 'UTF-8')

否则html_entity_decode将ISO 8859-1视为默认值。

答案 1 :(得分:1)

检查您的标头编码,看看您是否正在发送正确的编码。

utf-8编码的示例。

header('Content-Type: text/html; charset=utf-8');

答案 2 :(得分:0)

尝试将网页的编码类型设置为utf-8,例如:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />