VC Implementation URL Codec

Source: Internet
Author: User

    BOOL Decodeurl (char *src, char *url, int maxlen) {if (NULL = = URL | |          NULL = = SRC) {return false;          } if (MaxLen = = 0) {return false;  } char *p = SRC;    Used to loop int i = 0;          I used to control the URL array/* Temporarily save URL encoded data such as:%1A%2B%3C */char t = ' + ';                  while (*p! = ' \ ' && maxlen--) {if (*p = = 0x25)//0x25 = '% ' {                  /* The following are the usual uppercase letters, lowercase letters, numbers in hexadecimal numbers * * * if (p[1] >= ' A ' && p[1] <= ' Z ')//capital letters  {t = p[1]-' A ' + 10;                  A = 10, same as} else if (p[1] >= ' A ' && p[1] <= ' z ')//lowercase Letter                  {t = p[1]-' a ' + 10; } else if (p[1] >= ' 0 ' && p[1] <= ' 9 ')//number {T = P[1]-' 0 ';  } t *= 16;                      Put the number on 10 bit up if (p[2] >= ' A ' && p[2] <= ' Z ')//capital Letter {                  T + = p[2]-' A ' + 10; } else if (p[2] >= ' A ' && p[2] <= ' z ')//lowercase letter {T + =                  P[2]-' a ' + 10; } else if (p[2] >= ' 0 ' && p[2] <= ' 9 ')//number {T + = p[                  2]-' 0 ';                        }//To this composite a hexadecimal number url[i] = t;              p + = 3, i++; } else {//does not have URL-encoded data//' + ' special handling. It's equivalent to a space I                  F (*p! = ' + ') {url[i] = *p;                  } else {url[i] = 0x20;                  } i++;    p++;          }} Url[i] = ' + ';      Terminator return true;   }

VC Implementation URL Codec

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.