Showing posts with label encode url. Show all posts
Showing posts with label encode url. Show all posts

Friday, July 29, 2011

How to Really Encode URL

Apparently there is an issue with stringByAddingPercentEscapesUsingEncoding.  It doesn't escape things like +,&,/.  To escape a string properly for a URL, use the following:



NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)unencodedString,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );



This was found here: http://simonwoodside.com/weblog/2009/4/22/how_to_really_url_encode/
Using search terms: obj c encode url