//ios Url Encode
//有時候在請求的參數裡裡特殊符號比如“+”等。而如果沒有encode的話那麼傳過去的還是” ”,面實際上是%2B。 -(NSString*)UrlValueEncode:(NSString*)str { NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8); [result autorelease]; return result; } //- (NSString*)URLDecodedString:(NSString*)str //{ //// NSString *result = [[self stringByReplacingOccurrencesOfString:@"%0D%0A" withString:@""] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // NSString *result = [[str stringByReplacingOccurrencesOfString:@"%0D%0A" withString:@""] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // return [result stringByReplacingOccurrencesOfString:@"+" withString:@" "]; //}