PHP 字符编码 �签名而不是 à
您好,这是一个非常奇怪的错误,我在这个 joomla 网站的某些页面上遇到了这个错误:
如果您进入特定新闻的详细信息,à 字符会正确显示。
其他重音字符似乎不受影响。
我已经检查过 MySql 数据库中默认使用 UTF-8 编码,并且文本文件也采用 UTF-8 编码。
还有其他想法吗?
Hi this is a very strange error I have on some pages of this joomla website:
If you go into the details of a specific news the à character is correctly displayed.
Other accented characters seem not affected.
I've checked that UTF-8 encoding is default both in the MySql db and that the text files are in UTF-8 encoding.
Other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的情况非常有趣的是,它只影响字母
à
!所以不可能是编码问题。这是我对你的问题的看法。字母
à
在 utf8 中以两个字节编码。第一个字节是xC3
,即 latin-1 中的à
,第二个字节是...不间断空格! (其他重音字母,例如è
在 latin-1 中由à
编码,后跟其他重音字母,并且不受影响)。因此,我的猜测是,您在某处有一个脚本,可以删除或替换 latin-1 中的不间断空格,即字符
xA0
。生成的孤独字节xC3
无法正确显示,因此会显示通用占位符�
。 (只需以 latin-1 加载您的页面,您就会发现我是对的)。找到删除不间断空格的脚本,就可以了。
What is very interesting in your case is that it only affects the letter
à
! So it cannot be an encoding problem.Here is my take on your problem. The letter
à
is encoded in two bytes in utf8. The first byte isxC3
, which isÃ
in latin-1, the second byte is... non breaking space! (The other accented letters, such asè
are encoded byÃ
followed by an other accented letter in latin-1, and they are not affected).Therefore, my guess is that you have a script, somewhere, that removes, or replaces, the non-breaking space in latin-1, i.e., character
xA0
. The resulting lonely bytexC3
cannot be displayed properly, so the general placeholder�
is displayed instead. (just load your page in latin-1, you will see that I am right).Find that script that removes non-breaking spaces, and you'll be fine.
您是否有机会在从数据库检索的文本上使用
htmlentities
、htmlspecialchars
或html_entity_decode
?如果是这样,您需要在第三个参数中强制使用 UTF8,因为它不是这些函数的默认字符集。示例:
htmlentities('£hello', null, 'utf-8');
Are you by any chance using
htmlentities
,htmlspecialchars
orhtml_entity_decode
on the text you retrieved from the database ? If so, you need to force UTF8 in the third parameter because it's not the default charset of these functions.Example:
htmlentities('£hello', null, 'utf-8');
� 符号通常表示浏览器尝试显示的字符在所使用的字体中不可用。如果它适用于其他页面(使用相同的字体),它可能不是 à。
A � sign is usually an indication that the character the browser is trying to display is not available in the font used. It's probably not an à, if that works on other pages (using the same font).