How to convert php unicode encoding to Chinese characters

藏色散人
Release: 2023-03-08 15:16:01
Original
3762 people have browsed it

php Method to convert unicode encoding to Chinese characters: First create a PHP sample file; then use the "function unicodeDecode($unicode_str){...}" method to convert unicode characters into Chinese.

How to convert php unicode encoding to Chinese characters

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

unicode decoding method, convert unicode characters into Chinese, the code is as follows:

function unicodeDecode($unicode_str){ $json = '{"str":"'.$unicode_str.'"}'; $arr = json_decode($json,true); if(empty($arr)) return ''; return $arr['str']; } $unicode_str = "\u65b0\u6d6a\u5fae\u535a"; echo unicodeDecode($unicode_str);
Copy after login

Unicode decoding result: "Sina Weibo"

[Recommended study: "PHP video tutorial》】

The above is the detailed content of How to convert php unicode encoding to Chinese characters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!