我有这个 URL: http: //google.com并使用它进行 urlencode:
NSArray *escapeChars = [NSArray arrayWithObjects:@";" , @"/" , @"?" , @":" ,
@"@" , @"&" , @"=" , @"+" ,
@"$" , @"," , @"[" , @"]",
@"#", @"!", @"'", @"(",
@")", @"*", nil];
NSArray *replaceChars = [NSArray arrayWithObjects:@"%3B" , @"%2F" , @"%3F" ,
@"%3A" , @"%40" , @"%26" ,
@"%3D" , @"%2B" , @"%24" ,
@"%2C" , @"%5B" , @"%5D",
@"%23", @"%21", @"%27",
@"%28", @"%29", @"%2A", nil];
int len = [escapeChars count];
NSMutableString *temp = url;
int i;
for(i = 0; i < len; i++)
{
[temp replaceOccurrencesOfString: [escapeChars objectAtIndex:i] withString:[replaceChars objectAtIndex:i] options:NSLiteralSearch range:NSMakeRange(0, [temp length])];
}
return temp;
这是我得到的编码字符串:http0X1.D49C41C5D49CP-5700.0000000.000000google.com
怎么会这样?