Convert the flex string to hexadecimal

Source: Internet
Author: User

Recently I made a flex protocol. I want to send the username and password strings in hexadecimal notation to the server, so I am going to search for the solution on the Internet.

 

 

Found a good one, number (username. Text). tostring (16), username is the ID of the label Control

 

However, if the username text is not a pure number, such as a100, the result is Nan undefined.

 

Continue to find the charcodeat method of string. convert a single character to an ascii code. How can this problem be solved?

 

For (I = 0; I <username. Text. length; I ++) trace (username. Text. charcodeat (I). tostring (16 )); 

So far.

 

After conversion, use. fromcharcode (ASCII code 1, ASCII Code 2 ,...);

 

Trace ("New String:" + String. fromcharcode (68,97, 114,111,110 ));

However, the fromcharcode method is a static method. Note the following:

 

Write it down to reserve

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.