Copy strings URL-escaped The function [[strcpy_escaped]] copies [[s2]] to [[s1]] and escapes the result, according to the rules for URLs: characters [[/?=#%]] and space are coded as [%XX]], where [[XX]] is the hexadeciaml code for the character. [[s1]] must have enough room; no check is made. The function returns a pointer to [[s1]]. <<*>>= #include #define hex(n) ((n) < 10 ? (n) + '0' : (n) + 'A' - 10) EXPORT int URL_strcpy_escaped(char *s1, const char *s2) { char *t = s1; for (; *s2; s2++) if (*s2 == '/' || *s2 == '+' || *s2 == '?' || *s2 == '#' || *s2 == '%' || *s2 <= ' ' || *s2 == '\177' || *s2 == ':' || *s2 == '@') { *t++ = '%'; *t++ = hex(*s2/16); *t++ = hex(*s2 % 16); } else *t++ = *s2; *t = '\0'; return t - s1; }