Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[prog-challenge] In-Place URL Encoding

Name: Anonymous 2009-01-17 7:23

Using the encoding ranges specified in the following function

URLencode(char *out, char *in) {
 char a;
 while((a=*in)) {
  if((a>='A')&&(a<='Z')||(a>='a')&&(a<='z')||(a>='0')&&(a<='9')||(a=='-')||
     (a=='_')||(a=='.')||(a=='~')) {
   *(out++) = a;
  } else {
   sprintf(out,"%%%02x",a);
   out+=3;
  }
  in++;
 }
 *out=0;
}


Write an equivalent function which can URL-encode a string in-place, i.e. assuming the buffer is large enough (thrice the length of the original string), a call such as URLencode(str) will write the URL-encoded version in the same buffer, possibly lengthened to up to thrice its original length.

Your function cannot use any additional storage space that grows proportionally with the length of the string. The smallest, fastest, and most efficient implementations win.

Name: Anonymous 2009-01-17 10:16

>>18
GTFO, please.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List