字符串转译
NSString *url = @"https://www.baidu.com/s?ie=UTF-8&wd=%E6%88%91%E7%9A%84%E5%89%8D%E5%8D%8A%E7%94%9F";
CFStringRef encodedCFString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(__bridgeCFStringRef) url,
nil,
CFSTR("?!@#$^&%*+,:;='\"`<>()[]{}/\\| "),
kCFStringEncodingUTF8);
NSString*encodedString1 = [[NSStringalloc]initWithString:(__bridge_transferNSString*) encodedCFString];
NSString *charactersToEscape = @"?!@#$^&%*+,:;='\"`<>()[]{}/\\| ";
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];
NSString *encodedUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
NSLog(@"\n%@\n%@\n%@",encodedUrl,encodedString1);
参考资料:http://blog.csdn.net/lidongxuedecsdn/article/details/50497998