PHP generated JSON data from MySQL, Chinese has related problems

Source: Internet
Author: User
PHP generated JSON data from MySQL, Chinese is problematic.
MySQL is UTF8 code, json.php is UTF8 code, in the database, the Direct query table, the Chinese can be displayed correctly.

In the PHP program,

mysql_query ("Set names UTF8"); Use this to set the encoding.

UrlDecode (Json_encode ($newData)) This is the generation of JSON.

But the Chinese do not come out ah, the result is as follows:

Nutrition ":" \u7c73\u996d\u7684\u4e3b\u8981\u6210\u5206\u662f\u78b3\u6c34\u5316\u5408\u7269\uff0c\u7c73\u996d\ U4e2d\u7684\u86cb\u767d\u8d28\u4e3b\u8981\u662f\u7c73\u7cbe\u86cb\u767d\uff0c\u6c28\u57fa\u9178\u7684\u7ec4\ U6210\u6bd4\u8f83\u5b8c\u5168\uff0c\u4eba\u4f53\u5bb9\u6613\u6d88\u5316\u5438\u6536\u3002\u7cd9\u7c73\u996d\ U4E2D\U7684\U77FF\U7269\U8D28\U3001\U81B3\U98DF\U7EA4\U7EF4\U3001B\U65CF\U7EF4\U751F\U7D20 (\u7279\u522b\u662f\ U7EF4\U751F\U7D20B1) \u542b\u91cf\u90fd\u8f83\u7cbe\u7c73\u7c73\u996d\u4e2d\u7684\u8981\u9ad8\u3002 "," Consumption_effect ":" \u5927\u7c73\u6027\u5e73\u3001 "

This is the result of the Chinese characters.

How to solve?

------Solution--------------------
The Chinese JSON is originally a Unicode-encoded string representation.
------Solution--------------------


Baidu Search the first article, you can see the answer.

JSON Chinese code phpnewnew site:csdn.net
------Solution--------------------
Dizzy, I Google Json_decode site:w3school.com.cn unexpectedly did not search ...
  • 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.