unicode to Chinese

WBOY
Release: 2016-08-08 09:21:28
Original
1586 people have browsed it

Today I encountered a problem of converting unicode characters back to Chinese. After searching, it seems that PHP does not have a special built-in function for this.

After searching the Internet, some netizens posted their own encapsulated php tools. The functions can be realized, but it is a bit troublesome to introduce a method to solve this problem.

Later I thought that after we json_encode the Chinese string, we will get the Chinese unicode string. Can we use json_decode to solve this problem?

The answer is yes, but what I mean is that outside the unicode string, must be wrapped in a layer of double quotes

<span style="color:#330033;"><?php
$str = &#39;\u9a6c\u4e1c&#39;;
echo json_decode(&#39;"&#39; . $str . &#39;"&#39;);

//马东</span>
Copy after login

Copyright statement: This article is an original article by the blogger and may not be used without the blogger's permission. Reprint.

The above has introduced the conversion of unicode to Chinese, including aspects of it. 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