PHP json_encode UTF8 Chinese code 65u02f. How to solve?

Source: Internet
Author: User
mysql_query ("Set names ' UTF8 '");



I've already written this, but it's still like this.
MySQL database is also UTF8


Reply to discussion (solution)

Json_encode default is the HTML entity that converts Chinese into Unicode.
If your PHP version is greater than or equal to 5.4.0, you can

$s = ' Chinese '; Echo json_encode ($s, json_unescaped_unicode);
Chinese

Json_encode default is the HTML entity that converts Chinese into Unicode.
If your PHP version is greater than or equal to 5.4.0, you can

$s = ' Chinese '; Echo json_encode ($s, json_unescaped_unicode);
Chinese


My version is 5.2.6 how to do.

The system is Mac:

Well, that could happen.

$a = Array (' Chinese ', Aray (' Chinese ')); Echo Preg_replace_callback ('/\\\u (. { 4})/', ' foo ', Json_encode ($a)), function foo ($m) {  return iconv (' ucs-2 ', ' Utf-8 ', pack (' h* ', $m [1]);}
["Chinese", ["Chinese"]]
  • 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.