IOS How to encode url
/* encode url when request to server */
+ (NSString *) urlEncode:(NSString *)string {
NSString *urlEn = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)string, NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
return urlEn;
}
+ (NSString *) urlEncode:(NSString *)string {
NSString *urlEn = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)string, NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
return urlEn;
}
Comments
Post a Comment