void sgcgi_url_unescape(char *string) {
int len = strlen(string);
char *ptr = string;
char ord[3]; // buffer for ordinal character value string
while(*ptr) {
if(*ptr == '%') {
strncpy(ord,ptr+1,2);
long ord_l = strtol(ord,(char **)NULL,16);
if( ord_l && ord_l > 0 && ord_l < 256 ) {
*ptr = (char)ord_l;
strcpy(ptr+1,ptr+3);
}
}
else if(*ptr == '+') {
*ptr = ' ';
}
ptr++;
}
return;
}