发送的网络请求中含有中文 转码的实现

//    1.设置请求路径

self.username.text=@"博客园";

self.pwd.text=@"百度一下";
2     NSString *urlStr=[NSString stringWithFormat:@"http://192.168.1.53:8080/MJServer/login?username=%@&pwd=%@",self.username.text,self.pwd.text];
3    //转码
4    urlStr= [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
5     NSURL *url=[NSURL URLWithString:urlStr];
6    
7 //    2.创建请求对象
8     NSURLRequest *request=[NSURLRequest requestWithURL:url];

原文地址:https://www.cnblogs.com/520myp1314/p/4403485.html