Skip to content

Instantly share code, notes, and snippets.

@satoshin2071
Created July 11, 2013 08:25
Show Gist options
  • Save satoshin2071/5973583 to your computer and use it in GitHub Desktop.
Save satoshin2071/5973583 to your computer and use it in GitHub Desktop.
objc url encode & decode
//encoding
NSString *escapedUrlString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)plainString,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
//decoding
NSString *decodedUrlString = (NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(
NULL,
(CFStringRef) escapedUrlString,
CFSTR(""),
kCFStringEncodingUTF8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment