所有的是UTF8,但我仍然有奇怪的字符 [英] All is on UTF8 but I still got strange char like �

查看:120
本文介绍了所有的是UTF8,但我仍然有奇怪的字符 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库是utf8_general_ci,表格&列也是utf8_general_ci。
Php文件也保存在UT8中,我得到的标头在UTF8,所以...一切都是UTF8。

My database is "utf8_general_ci", tables & columns are also "utf8_general_ci". Php file is also saved in UT8, I got the header in UTF8, so ... everything is UTF8.

但我还有那个 字符有口音。

But I still got that � char when there is accents.

我用iconv检查,它是UTF8。
我也测试了编码与mb_detect_encoding和结果是相同的UTF8。

I checked with iconv and it is UTF8. I also tested the encoding with mb_detect_encoding and the result is the same UTF8.

这让我疯了...

我有一件事要工作:utf8_encode($ string)this给我Actualité而不是Actualit s

I got one thing to work : utf8_encode($string) this give me "Actualité" instead of "Actualit�s"

推荐答案

如何解决这个问题?

好的,我终于让它工作。感谢Mark Ba​​ker。这是我使用的解决方案。

Ok, I finally make it work. Thanks Mark Baker. Here is the solution I used.

我刚刚添加到我的PDO层:

I just added this to my PDO layer :

$dbh = new PDO('mysql:charset=utf8mb4');

还有另外两种方法,在这里进一步阅读:UTF-8一路通过

There are also 2 other ways to do it, read further here : UTF-8 all the way through

这篇关于所有的是UTF8,但我仍然有奇怪的字符 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆