All is on UTF8 but I still got strange char like �

只谈情不闲聊 提交于 2019-12-24 04:44:26

问题


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.

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

This drive me crazy ...

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

Is it possible this has been double-utf8 encoded ?

How can I fix this ?


回答1:


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

I just added this to my PDO layer :

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

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



来源:https://stackoverflow.com/questions/31382524/all-is-on-utf8-but-i-still-got-strange-char-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!