编解码的网站,必须编译出很多%才是正确的
中文和特殊字符 苹果自带的方法是解不了的—–需要自己去控制,以下是代码
- (NSString *)encodeToPercentEscapeString: (NSString *) input { NSString *outputStr = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)input, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8); return outputStr; } - (NSString *)decodeFromPercentEscapeString: (NSString *) input { NSMutableString *outputStr = [NSMutableString stringWithString:input]; [outputStr replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [outputStr length])]; return [outputStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; }