PHP mysql UTF-8 encoding problem
There is such a UTF-8 coded "\xe6\x93\x8d\xe4\xbd\x9c"
The correct value is assigned directly to the output in the page.
$subject = "\xe6\x93\x8d\xe4\xbd\x9c";
$subject =mb_convert_encoding ($subject, "GB2312", "UTF-8");
Echo $subject;
?>
But put the record in the database, read the conversion has not changed, input or "\xe6\x93\x8d\xe4\xbd\x9c";
Which great God has encountered similar problems, please advise, thank you
------Solution--------------------
"\xe6\x93\x8d\xe4\xbd\x9c" in the program
A representation of the hexadecimal inner code of the UTF-8 encoded operation (must be enclosed in double quotes)
Otherwise it's just a bunch of \xe6\x93\x8d\xe4\xbd\x9c.
Only those written in the program will be converted, not the outside.
For string \xe6\x93\x8d\xe4\xbd\x9c this can be converted
$s = ' \xe6\x93\x8d\xe4\xbd\x9c ';
Echo Hex2bin (Str_replace (' \x ', ', $s));
Echo UrlDecode (Str_replace (' \x ', '% ', $s));