Home > Backend Development > PHP Tutorial > Unicode character set makes Json understand Chinese better JSON_UNESCAPED_UNICODE

Unicode character set makes Json understand Chinese better JSON_UNESCAPED_UNICODE

WBOY
Release: 2016-07-29 08:46:59
Original
997 people have browsed it

Copy the code The code is as follows:


echo json_encode("Chinese"); //"u4e2du6587"


This gives us developers in China a headache, Sometimes you have to write json_encode yourself.
In PHP5.4, this problem has finally been solved. Json has a new option: JSON_UNESCAPED_UNICODE, so the name is incredible, that is, Json does not need to be encoded in Unicode.
Look at the example below:

Copy the code The code is as follows:


echo json_encode("中文", JSON_UNESCAPED_UNICODE); //"中文"


How about it, is it a change that makes everyone happy? Haha, of course, Json has also added: JSON_BIGINT_AS_STRING, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES and other options in 5.4. If you are interested, you can refer to: json_encode

However, I still have to remind you: PHP 5.4 is still in the development stage. Before the final release, any New features may be adjusted or changed. If you have any suggestions, feedback is also welcome to help us make PHP better.
From: http://www.laruence.com

The above introduces the unicode character set to make Json understand Chinese JSON_UNESCAPED_UNICODE better, including the unicode character set. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template