[英]PHP & MySQL special character encoding problem
When a user submits a special character ♠
当用户提交一个特殊字符
♠
it's stored in MySQL database as â
and if a user wants to change it instead of displaying it back as ♠
它以
â
的形式存储在MySQL数据库中,如果用户想更改它而不是将其显示为♠
its displayed as â
how can I fix this problem so that its dsiplayed back as ♠
其显示为
â
我怎么能解决这个问题,以便其dsiplayed早在♠
and saved as ♠
并另存为
♠
? ?
On a side note how should I save my special characters using PHP? 附带说明一下,如何使用PHP保存特殊字符?
I'm using PHP & MySQL 我正在使用PHP和MySQL
That's could be a problem. 那可能是个问题。
If you want to convert your special characters into entities, you have to htmlencode them twice when outputting into field value/textarea content. 如果要将特殊字符转换为实体,则在输出为字段值/文本区域内容时必须对它们进行html编码两次 。 But it could mess with other characters - all become their entity representations - quotes, brackets and such.
但这可能会与其他字符(全部成为其实体表示形式),引号,方括号等混淆。 If it's what you're asked for - go ahead.
如果这是您的要求-继续。 But, in my opinion, it could be a terrible mess to edit such a text.
但是,在我看来,编辑这样的文本可能是一团糟。
That's why it's better not to let users to use entities. 这就是为什么最好不要让用户使用实体。 Why can't they enter the symbol itself?
他们为什么不能输入符号本身?
As for the special characters in your database - just use UTF-8 encoding in both database and HTML. 至于数据库中的特殊字符-只需在数据库和HTML中都使用UTF-8编码即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.