NSString+URLEncoding 分类

#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>

@implementation NSString (URLEncoding)
-(NSString*)URLEncodedString {
    CFStringRef StringRef = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("+$,#[] "), kCFStringEncodingUTF8);
    NSString *result = (NSString*)CFBridgingRelease(StringRef);
    return result;
}

-(NSString*)URLDecodedString {
    CFStringRef stringRef = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)self, CFSTR(""), kCFStringEncodingUTF8);
    NSString *result = (NSString*)CFBridgingRelease(stringRef);
    return  result;
}
@end