NSString + URLEnconding

NSString *urlString=@"http://ios-sdk.blogspot.com";

NSString* escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];



//advanced encoding function below:

- (NSString *)encodeString:(NSString*)str

{

return (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)str,

NULL, (CFStringRef)@"%';:!?*()#@&$/=+{}<>[],",

kCFStringEncodingUTF8);

}

No comments:

Post a Comment