我在Wordpress中使用插件,在一个字段中存储一些HTML代码。
此列为mediumtext utf8_general_ci
当我想输出此信息时,所有特殊字符(例如" ´ ' ...
和其他字符)都会显示为带有问号的黑色菱形�
当插件显示此文本时,它是完美的。这是在头脑中:
<meta charset="UTF-8" />
当我在其他地方输出时,我脑子里就有这个,所有这些角色都丢失了:
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
字符正确存储在MYSQL中,我通过PHP输出它
ob_start();?>
some html
<?php echo $row4['details'];?> <- this is the field im talking about
some html
<?php
$details = ob_get_clean();
以后只是:
echo $details;
我已经阅读了足够的内容并且总是提到字符集,但我认为我的确很好。
感谢您的帮助!
编辑:添加完整示例
WP中显示的文字。正如我在评论中所说,这可能是由编辑从MS Word复制/粘贴到Worpress的。
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, “Time is gold”?
Has… heard…
Have… hear…
Have… heard…
像这样存储在数据库中(不要查看正确/正确的用户答案)
<span class='watupro_num'>8. </span>Choose the verb to complete the sentence.</p>
<p>______ you ever _____ the proverb, “Time is gold”?</p></div>
<ul>
<li class='answer'><span class='answer'>Has… heard…</span></li>
<li class='answer user-answer'><span class='answer'>Have… hear…</span></li>
<li class='answer correct-answer'><span class='answer'>Have… heard…</span></li>
</ul>
从数据库中显示的文本(即时工作)
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, �Time is gold�?
Has� heard�
Have� hear�
Have� heard�
utf8_encode()
之后显示的文字归功于Kirit Patel
8. Choose the verb to complete the sentence.
______ you ever _____ the proverb, Time is gold?
Has heard
Have hear
Have heard
我刚刚发现角色还在那里。编辑时我可以看到一个带数字的框(未在预览中显示)。
答案 0 :(得分:4)
您可以像
一样使用<?php
echo utf8_encode($row4['details']);
?>
希望这会对你有所帮助。
答案 1 :(得分:0)
0093
,这是一个无效的 utf8 代码,用于引用某些内容;另一方面,解释为 latin1 的十六进制93是“
。
你能简单地切换到ascii引号和撇号吗?
否则,您需要始终使用utf8 - 从生成hex 93的任何内容开始。