Changeset 21 in Main for trunk/Common/string.c
- Timestamp:
- Sep 14, 2024, 9:39:39 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/string.c
r20 r21 160 160 return result; 161 161 } 162 163 char* cm_url_escape(const char* str) { 164 int i; 165 char* result = malloc(1); 166 result[0] = 0; 167 char cbuf[2]; 168 cbuf[1] = 0; 169 for(i = 0; str[i] != 0; i++) { 170 cbuf[0] = str[i]; 171 if('!' <= str[i] && str[i] <= '@' && str[i] != '.' && str[i] != '-' && str[i] != '/' && !('0' <= str[i] && str[i] <= '9')) { 172 char code[4]; 173 sprintf(code, "%%%02X", str[i]); 174 char* tmp = result; 175 result = cm_strcat(tmp, code); 176 free(tmp); 177 } else { 178 char* tmp = result; 179 result = cm_strcat(tmp, cbuf); 180 free(tmp); 181 } 182 } 183 return result; 184 }
Note:
See TracChangeset
for help on using the changeset viewer.