[英]Special characters issue in PHP
I am working on a project where a user enters his info and I save it into database, a user posted a string in the form " I still am… ". 我正在一个项目中,用户输入他的信息并将其保存到数据库中,一个用户以“ 我仍然是…… ”的形式发布了一个字符串。 But the string stored in database as " I still am… ".
但是存储在数据库中的字符串为“ 我仍然是 ”。
Now I am wondering why this happened, by looking at the string it is cleared that the suffix used after am is a kind of special characters and is converted into …
. 现在,我想知道为什么会发生这种情况,通过查看字符串,可以清楚地看到am之后使用的后缀是一种特殊字符,并转换为
…
。
You have to set the UTF-8 as the connection to a database too. 您还必须将UTF-8设置为与数据库的连接。 It is set to Windows 1252 by default.
默认情况下,它设置为Windows 1252。 (This encoding is often incorrectly labelled ISO 8859-1.)
(此编码通常被错误地标记为ISO 8859-1。)
The bytes E2 80 A6
are rendered as …
in UTF-8 and as …
in Windows 1252. The PHP is most of the time unaware of an encoding and pass raw bytes. 该字节
E2 80 A6
被渲染为…
在UTF-8和…
在Windows 1252的PHP是大多数时候不知道的编码,并通过原始字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.