码迷,mamicode.com
首页 > 移动开发 > 详细

IOS encode解码与编码

时间:2016-11-12 02:27:54      阅读:1129      评论:0      收藏:0      [点我收藏+]

标签:ios

/**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];
}


本文出自 “雪花飞落满人间” 博客,请务必保留此出处http://smengxiang.blog.51cto.com/11204872/1871973

IOS encode解码与编码

标签:ios

原文地址:http://smengxiang.blog.51cto.com/11204872/1871973

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!