Refer to NSString stringByAddingPercentEscapesUsingEncoding:
you should use CFURLCreateStringByAddingPercentEscapes
to custom which character you want to escape.
- (NSString *) urlencodeStr:(NSString *)str
{
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef) str,
NULL,
CFSTR("!*'();:@+$,/?%#[]"),
kCFStringEncodingUTF8));
}
CFSTR("!*'();:@+$,/?%#[]")
contains the characters will be escaped.