Ascii code. What should I do if I see a code on the Internet?

Source: Internet
Author: User
Ascii code. PHPcode & lt ;? Php *** ASCII to hexadecimal and hexadecimal to ASCII * non-profit organizations or individuals may feel free to reprint them, for commercial purposes, please obtain the author's consent ** convert ASCII to hexadecimal functionasc2hex ($ str) {returnx. substr (chunk_split (bin2hex (ascii Chinese characters. Code displayed on the Internet
PHP code
  
  "; Echo" asc: ". $ asc;?>


Utf8 is used for saving,

Question 1: Haha is UTF-8 encoded ?? Why can a function be converted from ascii to hexadecimal. The result is \ xe5 \ x93 \ x88 \ xe5 \ x93 \ x88.

I have checked that the hexadecimal format of Haha's ascii code is 54c8 54c8, which is obviously different.

Cannot understand



------ Solution --------------------
It is not appropriate to use "ascii" here, but "convert to hexadecimal,
The function is actually used to represent the string encoding in hexadecimal format.

So all your questions are justified.

It is also funny to write "not-for-profit organizations or individuals can reprint them with confidence, and ask the author's consent for commercial purposes" on the function head,
Because such a simple code is not original, you can write the same code without looking at it,
Therefore, you certainly do not need to "obtain the author's consent"

Discussion
PHP code
/**
*
* Convert ASCII to hexadecimal and hexadecimal to ASCII
* For non-profit organizations or individuals, please feel free to repost them. for commercial purposes, please obtain the author's consent.
*
*/
// Convert ASCII to hexadecimal
Function asc2hex ($ str ){
Return '\ X'. substr (chunk_split (bin2hex ($ str), 2,' \ X'), 0,-2 );
}
// Convert the hexadecimal format to ......

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.