我坚持在URL中发送Unicode字符(印地语)作为参数。它在服务器上以不可接受的格式到达。它在控制台中正确打印,但在使用方法urlWithString:转换为NSURL时,字符串将转换为不可读的格式。 值得注意的事实是,如果服务器直接从数据库中的更改发送它,我能够用印地语正确读取。
编辑:(添加代码)
NSURL *url = [NSURL URLWithString:[completeURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
request = [ASIHTTPRequest requestWithURL:url];
[ASIHTTPRequest setDefaultUserAgentString:@"ipad"];
[request setAllowCompressedResponse:YES];
[request setShouldContinueWhenAppEntersBackground:YES];
request.requestMethod = requestType;
[request setTimeOutSeconds:180];
[request setCachePolicy:ASIUseDefaultCachePolicy];
[request addRequestHeader:@"Content-Type" value:@"text/json; charset=UTF-8"];
//request.responseEncoding = NSUTF8StringEncoding;
request.defaultResponseEncoding = NSUTF8StringEncoding;
[request setValidatesSecureCertificate:NO];
[request startSynchronous];