home|blog|IOS – URL ENCODE

iOs – Url encode

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 );
}
share:

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*