iOs - Url encode

2 min read
The stringByAddingPercentEscapesUsingEncoding function doesn't translate all characters for URL encoding.

To encode all characters I use the CFURLCreateStringByAddingPercentEscapes function as follow:


- (NSString*) encodeUrlString:(NSString*)unencodedString {
return (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)unencodedString,NULL,(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", kCFStringEncodingUTF8 );
}
This website uses cookies. By continuing to browse the site you are agreeing to our privacy policy.By closing this banner or clicking on any other item of this page, you agree to the use of such cookies.