Unicode encoding online conversion tool--javascript

Source: Internet
Author: User

Unicode encoding online conversion tool--javascript

I search on the Internet, see the use of JavaScript to do Unicode encoding conversion, feel very fun, so take to use.
This feature has been tested for both of the current:
1) Unicode converts each other, for example \u4e2d\u56fd to characters, and supports both Chinese and English;
2) URL encoding parsing, such as the well-known%20 is to represent the space, there are%24,%33,%44,%62 and so on;
I believe that as long as you try to decode the characters above, you will know the relationship between them, how to represent characters, numbers, and letters.



The above can be run directly. The following is the relevant JS code, as follows:

<script type= "Text/javascript" >//<! [Cdata[varDecToHex =function(str) {varres=[];  for(varI=0;i < str.length;i++) Res[i]= ("xx" +str.charcodeat (i). toString ()). Slice (-4); return"\\u" +res.join ("\\u");}varHextodec =function(str) {str=str.replace (/\\/g, "%"); returnunescape (str);}varBianma=function() {document.getElementById (' Code12 '). Value=dectohex (document.getElementById (' Code11 ')). value);}varJiema=function() {document.getElementById (' Code12 '). Value=hextodec (document.getElementById (' Code11 ')). value);}//]]></script><p><textarea id= "Code11" style= "width:500px; height:100px; "rows=" 5 "cols=" height= "></textarea> <br/><input onclick=" Bianma () "Type=" Button "value=" encoded "/>&nbsp;<input onclick=" Jiema () "type=" button "value=" Decode "/><br/><textarea Id= "Code12" style= "width:500px; height:100px, "rows=" 5 "cols=" ></textarea></p>

Source: http://www.cnblogs.com/skykang/archive/2011/06/02/2068802.html

Unicode encoding online conversion tool--javascript

Related Article

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.