开发者

Send http request with Chinese words

NSString *urlAddress = @"http://www.test.com/test.jsp?Query=哈囉";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
NSURLResponse* myURLResponse; 
NSError* myError; 
NSData* data = [NSUR开发者_JAVA百科LConnection sendSynchronousRequest: requestObj returningResponse:&myURLResponse error:& myErr];

I want to use http get method to send request, but failed. English alphabets work well.

I.e., I want to convert "哈囉" to "%E5%93%88%E5%9B%89" so that the response will successfully return. It seems not to be converted by itself automatically.

Anyone could help me solve this problem?

Thanks a lot!


urlAddress = [urlAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

(docs)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜