/**decode编码*/
- (NSString *)encodeToPercentEscapeString
{
NSString*
outputStr = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL, /* allocator */
(__bridge CFStringRef)self,
NULL, /* charactersToLeaveUnescaped */
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
return
outputStr;
}
/**decode解码*/
- (NSString *)decodeFromPercentEscapeString
{
NSMutableString *outputStr = [NSMutableString stringWithString:self];
[outputStr replaceOccurrencesOfString:@"+"
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0,[outputStr length])];
return
[outputStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
网页标题:IOSencode解码与编码
URL网址:
http://bzwzjz.com/article/ggspgj.html