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 = '\u9a6c\u4e1c'; echo json_decode('"' . $str . '"'); //马东</span>
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.