/* URL encoding C version * Lin Jensen * Feb 21, 1999 25 Feb 2005 stripped down version * A new string is produced, URL encoded. Rules are * Alphanumeric chars unchanged * Space --> '+' * Special chars (the rest) --> "%hh" where hh is hexadecimal ************************************************************************/ void URLencode (const char * plain, char * encode){ register char ch; /* each char, use $s2 */ while (ch = *plain ++) { /* get char, test end of string, asciiz */ if (ch == ' ') * encode ++ = '+'; else if (AlphaNumeric (ch)) * encode ++ = ch; else { * encode ++ = '%'; * encode ++ = bin2hex (ch >> 4); /*shift right for left nibble*/ * encode ++ = bin2hex (ch); /* right nibble */ } } * encode = 0; /* store zero byte to terminate string */ } /* URLencode*/