Unicode decoding online Conversion Tool

Source: Internet
Author: User

Unicode decoding online Conversion Tool

Unicode is developed based on the standard of the Universal Character Set and also in the form of books (the Unicode standard, currently fifth edition published by Addison-Wesley professional, ISBN-10: 0321480910) external publication.

The latest Unicode version in July 2006 is 5.0. Unicode 4.1.0 was launched in March 31, 2005. In addition, the version 5.0 Beta was launched in December 12, 2005 and the version 5.2 (UNICODE standard) was officially launched in October 1, 2009 for comments by members.
Currently, the Unicode Standard Version 6.1 has been released (January 1, January 31, 2012 ). On the Unicode Alliance website, you can view the complete 6.1 core specifications.
Unicode defines a character set that is large enough to represent all human readable characters.

 

Enter the content to be encoded:



 

Enter the content to decode
 

 

PHP code implementation

<? Phpfunction unicode_encode ($ name) {$ name = iconv ('utf-8', 'ucs-2', $ name); $ Len = strlen ($ name ); $ STR = ''; For ($ I = 0; $ I <$ len-1; $ I = $ I + 2) {$ c = $ name [$ I]; $ C2 = $ name [$ I + 1]; If (ord ($ c)> 0) {// two bytes of text $ Str. = '\ U '. base_convert (ord ($ C), 10, 16 ). str_pad (base_convert (ord ($ C2), 10, 16), 2, 0, str_pad_left);} else {$ Str. = $ C2 ;}return $ STR ;}// decodes the unicode encoded content. Function unicode_deco De ($ name) {// convert the Unicode encoding to the UTF-8 encoding that can be viewed $ pattern = '/([\ W] +) | (\ U ([\ W] {4})/I '; preg_match_all ($ pattern, $ name, $ matches); If (! Empty ($ matches) {$ name = ''; For ($ J = 0; $ j <count ($ matches [0]); $ J ++) {$ STR = $ matches [0] [$ J]; If (strpos ($ STR, '\ U') = 0) {$ code = base_convert (substr ($ STR, 2, 2), 16, 10); $ code2 = base_convert (substr ($ STR, 4), 16, 10 ); $ c = CHR ($ code ). CHR ($ code2); $ c = iconv ('ucs-2', 'utf-8', $ C); $ name. = $ C;} else {$ name. = $ STR ;}}return $ name ;}

 

Reprinted: http://www.cnblogs.com/txw1958/archive/2013/04/20/unicode-encode-decode.html

Unicode decoding online Conversion Tool

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.