Last active
March 7, 2017 03:27
-
-
Save annidy/bec8c0a6040af88957d55e1f3d03e411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static char *url_escape(char *path, int len) { | |
char *org_path = strdup(path); | |
memset(path, 0, len); | |
char *enc = path; | |
for (char *s = org_path; *s && (enc - path < len - 3); s++) { | |
if (strchr("!*'();:@&=+$,/?%%#[]", *s) != NULL) { | |
sprintf(enc, "%%%02X", *s); | |
} else { | |
sprintf(enc, "%c", *s); | |
} | |
while (*++enc); | |
} | |
free(org_path); | |
return path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment