31 lines
545 B
C++
31 lines
545 B
C++
|
|
|
|
void urlencode(char* dest, char* src)
|
|
{
|
|
|
|
int i;
|
|
for(i = 0; i < strlen(src); i++) {
|
|
char c = src[i];
|
|
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
|
|
(c >= '0' && c <= '9') ||
|
|
c == '-' || c == '_' || c == '.' || c == '~') {
|
|
char t[2];
|
|
t[0] = c;
|
|
t[1] = '\0';
|
|
strcat(dest, t);
|
|
}
|
|
else {
|
|
if(c == '/') {
|
|
strcat(dest, "%252f");
|
|
}
|
|
else {
|
|
char t[4];
|
|
snprintf(t, sizeof(t), "%%%02x", c & 0xff);
|
|
strcat(dest, t);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|