Convert unicode encoding to Chinese in php-PHP source code

Source: Internet
Author: User
What I see most on the Internet is the conversion of Chinese characters to unicode encoding. Today we can see that the opposite operation is to convert unicode to Chinese, next, let's take a look at the most common Chinese character conversion unicode code on the Alibaba Cloud website. Today we can see that the opposite operation is to convert unicode to Chinese. Let's take a look at it.

Script ec (2); script


In the past two days, we helped others develop the platform's friends section to store all user-interests in unicode. After obtaining the content, we need to convert it into Chinese characters.

I checked some methods on the Internet, which is complicated and not particularly useful. Here I recommend a method:

Function unicode_decode ($ name ){

$ Json = '{"str": "'. $ name .'"}';
$ Arr = json_decode ($ json, true );
If (empty ($ arr) return '';
Return $ arr ['str'];

}

Use unicode encoding as a string, save the string in json, and assign a value to the array arr. The output arr value can be converted into Chinese characters.

$ Aihao = unicode_decode ("\ u7f8e \ u98df ");

Echo $ aihao;

Input result: Music


If you want to know Chinese characters converted to Unicode encoding PHP program can refer to the http://www.111cn.net/phper/php-cy/44986.htm

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.