PHP / Apache 问题与英镑符号 (£)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2111154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP / Apache issue with pound signs (£)
提问by Tim
I have some text stored in MySQL database like this "Tom gave Sarah £5 for her book". Up until last Monday this displayed on the site perfectly when pulled from the site, showing "Tom gave Sarah £5 for her book".
我在 MySQL 数据库中存储了一些文本,例如“Tom 给了 Sarah £5 买她的书”。直到上周一,当从网站上拉出时,它完美地显示在网站上,显示“汤姆为她的书给了莎拉 5 英镑”。
Now, even though I have not changed/installed/uninstalled/updated anything at all, it has stopped working.
现在,即使我根本没有更改/安装/卸载/更新任何东西,它也已停止工作。
The old values in the database are being displayed as "Tom gave Sarah ?£5 for her book". On the form that saves this text to database, where it used to save to database fine as "Tom gave Sarah £5 for her book", it is now saving as "Tom gave Sarah ?5 for her book", and displaying on the site as this as well ("Tom gave Sarah ?5 for her book").
数据库中的旧值显示为“汤姆给了莎拉?£5 为她的书”。在将此文本保存到数据库的表单上,它曾经保存到数据库的罚款为“汤姆给了莎拉 £5 为她的书”,现在保存为“汤姆给了莎拉 5 元给她的书”,并显示在网站也是如此(“汤姆给了莎拉?5 为她的书”)。
What would cause this? I am pulling my hair out to try and sort this out. I have been playing with utf8_encode/utf8_decode and using ISO-8859-1 and UTF-8 character set for the pages and although each method produces different results (eg "?5" / "?£5" / "??£5" / "?5" / "?5" ), none are right.
什么会导致这种情况?我正在拉我的头发试图解决这个问题。我一直在玩 utf8_encode/utf8_decode 并为页面使用 ISO-8859-1 和 UTF-8 字符集,尽管每种方法都会产生不同的结果(例如“?5”/“?£5”/“??£5” / "?5" / "?5" ),没有一个是正确的。
The problem can't be MySQL because I can see £ signs fine in phpMyAdmin and the £ signs work on a different web server.
问题不可能出在 MySQL 上,因为我可以在 phpMyAdmin 中看到 £ 符号正常,而 £ 符号在不同的 Web 服务器上工作。
Help!
帮助!
采纳答案by Alix Axel
Instead of repeating this over and over again, I'm just gonna leave you with a link:
与其一遍又一遍地重复,我只想给你一个链接:
UTF-8 all the way through…
UTF-8 一直贯穿……
If you follow the steps mentioned in chazomaticus answer, your problems will be gone.
如果您按照 chazomaticus 答案中提到的步骤进行操作,您的问题就会消失。
In your specific problem database / table / field encoding is probably the issue.
在您的特定问题中,数据库/表/字段编码可能是问题所在。
回答by bobby
If your database is set to utf8 that might not be enough. Make sure the connection character set is set to UTF8. Perform this query: 'SET NAMES utf8;'
如果您的数据库设置为 utf8,那可能还不够。确保连接字符集设置为 UTF8。执行此查询:'SET NAMES utf8;'

