【问题标题】:UTF-8 decoding error in PHP [duplicate]PHP中的UTF-8解码错误[重复]
【发布时间】:2018-04-02 09:52:52
【问题描述】:

我的数据库值为École Polytechnique Fédérale de Lausanne。我无法转换为 html 字符。我尝试使用以下方法进行转换,

echo html_entity_decode(École Polytechnique Fédérale de Lausanne');
echo html_entity_decode($Event['Event_speaker']);

第一个语句我得到了实际结果,第二个语句显示与 db 值完全相同。

在我的标题中使用

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

有人可以帮忙吗?

【问题讨论】:

  • 您的字符串中没有 HTML 实体。为什么叫 html_entity_decode?​​span>
  • “第二个显示与 db 值完全相同” – 好的,那么您正确地输出了数据库中的内容,这很好。问题是您的数据库中有垃圾。

标签: php html utf-8 string-decoding


【解决方案1】:

试试这个 PHP predefined function

<?php
$str = "École Polytechnique Fédérale de Lausanne";
echo iconv_mime_decode($str);

【讨论】:

  • 这不是 MIME 编码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-17
  • 2013-05-11
相关资源
最近更新 更多