NSString+URLEncoding.h
#import <Foundation/Foundation.h> @interface NSString(URLEncoding) - (NSString *)urlEncodeString; @end
NSString+URLEncoding.m
#import "NSString+URLEncoding.h" @implementation NSString(URLEncoding) - (NSString *)urlEncodeString { NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@";/?:@&=$+{}<>,", kCFStringEncodingUTF8); return [result autorelease]; } @end
时间: 2024-12-29 01:59:44