//URL解码 //-(NSString *)URLDecodedString:(NSString *)str //{ // NSString *decodedString=(__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (__bridge CFStringRef)str, CFSTR(" "), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); // // return str; //} //-(NSString*)UrlValueEncode:(NSString*)str //{ // NSString *result = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, // (__bridge CFStringRef)str, // NULL, // CFSTR("!*'();:@&=+$,/?%#[]"), // kCFStringEncodingUTF8); // return result; //} ////utf8解码,空格解码 //-(NSString *)decodeFromPercentEscapeString:(NSString *) input //{ // NSMutableString *outputStr = [NSMutableString stringWithString:input]; // [outputStr replaceOccurrencesOfString:@"+" // withString:@" " // options:NSLiteralSearch // range:NSMakeRange(0, [outputStr length])]; // // return [outputStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //} +(NSString*)URLDecodedString:(NSString*)str { NSString *result = [[str stringByReplacingOccurrencesOfString:@"%0D%0A" withString:@""] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; return [result stringByReplacingOccurrencesOfString:@"+" withString:@" "]; }