Something
public text v1 · immutablechar *urlencode(char *in)
{
char *out, *p, *q;
out = (char *)malloc(3 * strlen(in) + 1);
p = in;
q = out;
while (*p != '\0') {
if (isalnum(*p) || (*p == '_') || (*p == '-')) {
*q = *p;
++q;
} else {
sprintf(q, "%%%02X", *p);
q = &q[3];
}
++p;
}
*q = '\0';
return out;
}