PHP mysql UTF-8 encoding related issues

Source: Internet
Author: User
Tags php mysql
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));
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.