【问题标题】:encoding issue using php and mysql, wordpress使用 php 和 mysql、wordpress 的编码问题
【发布时间】:2012-07-27 23:54:17
【问题描述】:

我将以下文本手动输入到 wordpress 帖子表中

‚

我使用以下代码编码为 utf-8:

$text = "‚";
$enc = mb_detect_encoding($text, "UTF-8,ISO-8859-1");
$hotelDescription   = iconv($enc, "UTF-8", $text);

然而,当 wordpress 回显它时,它会显示

‚

有什么想法可以输出正确的字符吗?

【问题讨论】:

标签: php mysql wordpress utf-8


【解决方案1】:

您需要指定显示该字符串的页面使用 UTF-8 编码呈现。您发布的输出是该 utf-8 字符串的 iso-8859-1 版本。假设数据以 UTF-8 格式正确存储在数据库中,请确保呈现此字符串的页面具有以下元标记:

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

【讨论】:

    【解决方案2】:

    看起来您在 #226 之前缺少 &;

    【讨论】:

      猜你喜欢
      • 2013-04-25
      • 1970-01-01
      • 2010-12-15
      • 1970-01-01
      • 1970-01-01
      • 2010-09-29
      • 2023-03-23
      • 2021-02-26
      • 2011-06-12
      相关资源
      最近更新 更多