I have to post parameters to an url and i have a parameter that has a “=” char so I should escape it. Here attach what I’m doing in objective-C.
for (NSString* key in json) {
NSString *current = [NSString stringWithFormat:@"&%@=%@",key,[json objectForKey:key]];
[post appendString: current];
}
//so post has this style: "&password=eodhxgkpo=&usuario=user1"
NSURL *urlObj = [NSURL URLWithString: itemAddress];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: urlObj];
NSData *requestData = [NSData dataWithBytes:[post UTF8String] length:[post length]];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
[webView loadRequest: request];
this same code works if password has no “=” char. So there is any way to escape this kind of chars?
(the content-type has to be “application/x-www-form-urlencoded”)
Thanks for your help
Danilo
You have the list of escapes codes for URL here:
http://www.december.com/html/spec/esccodes.html
You have to use %3D for escaping =
Hope it helps!