PhpmysqlUTF-8 coding problems have such a UTF-8 code "\ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c"
It is correct to directly assign values to the output in the page.
$ Subject = "\ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c ";
$ Subject = mb_convert_encoding ($ subject, "GB2312", "UTF-8 ");
Echo $ subject;
?>
However, the record is stored in the database. the input is still "\ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c ";
Which of the following has encountered a similar problem? please advise. thank you.
Reply to discussion (solution)
Do not understand what you want to express
Let's take a look at the encoding of your database. it's not estimated that it's GB2312.
"\ Xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c" in the program"
A representation of the hexadecimal internal code of UTF-8 encoding operations (it must be enclosed by double quotation marks)
Otherwise, it's just a string like \ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c.
Only those written in the program will be converted, and none of others will.
You can convert the string \ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c in this way.
$s = '\xe6\x93\x8d\xe4\xbd\x9c';echo hex2bin(str_replace('\x', '', $s));echo urldecode(str_replace('\x', '%', $s));
"\ Xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c" in the program"
A representation of the hexadecimal internal code of UTF-8 encoding operations (it must be enclosed by double quotation marks)
Otherwise, it's just a string like \ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c.
Only those written in the program will be converted, and none of others will.
You can convert the string \ xe6 \ x93 \ x8d \ xe4 \ xbd \ x9c in this way.
$s = '\xe6\x93\x8d\xe4\xbd\x9c';echo hex2bin(str_replace('\x', '', $s));echo urldecode(str_replace('\x', '%', $s));
As the moderator said, this is correct. thank you!