把做工程過程比較重要的一些內容片段做個珍藏,下面內容內容是關於C語言對字符串進行轉義excape操作的內容,希望對大夥有些幫助。
{
int i = 0, j;
while( i < data_len ){
if( '%' != data[i]){
strncat(buf, data+i, 1);
i++;
continue;
}
j = 0;
while( NULL != transfer_table[j][1] ){
if( 0 == strncasecmp(data+i+1, transfer_table[j][1], 2 )){
strncat(buf, transfer_table[j][0], 1);
i += 3;
break;
}
j++;
}
if( NULL == transfer_table[j][1] ){
strncat(buf, data+i, 1);
printf("escape_url_character: unhandled sequence: %sn", data+i);
i++;
}
}
memset(data, 0, data_len);
strcpy(data, buf);
free(buf);
return 0;
}