`
zani
  • 浏览: 358578 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

[ASIHTTPRequest requestWithURL:url] url带中文时编码

 
阅读更多

1. url带中文时编码

NSString* urlString = [NSString stringWithFormat:@"http://60.190.20.174/NBHYYYServices/ZQSBUpload.aspx?type=aqjc&filename=%@", fileName]; 
	urlString = [urlString stringByAddingPercentEscapesUsingEncoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)];
 

2. setDownloadDestinationPath:使用注意点:

 通过设置request的setDownloadDestinationPath,可以设置下载文件用的下载目标目录。
首先,下载过程文件会保存在temporaryFileDownloadPath目录下。如果下载完成会做以下事情:
 1,如果数据是压缩的,进行解压,并把文件放在downloadDestinationPath目录中,临时文件被删除
 2,如果下载失败,临时文件被直接移到downloadDestinationPath目录,并替换同名文件。

  如果你想获取下载中的所有数据,可以实现ASIHTTPRequestdelegate中的 -(void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data方法。但如果你实现了这个方法,request在下载完后,request并不把文件放在downloadDestinationPath中,需要手工处理。

 

 

 

3. 中文编码:urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

分享到:
评论

相关推荐

    asihttprequest使用指南

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://example.com"]]; [request startSynchronous]; ``` ##### 1.2 创建一个异步请求 异步请求不会阻塞线程,是处理网络请求...

    ASIHttpRequest.rar

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com"]]; [request startAsynchronous]; ``` 对于POST请求,可以添加请求体: ```objc ASIFormDataRequest *...

    ASIHTTPRequest

    2. **创建请求**:使用`[ASIHTTPRequest requestWithURL:]`方法创建一个请求对象,传入目标URL。 3. **设置请求属性**:如设置请求方法、HTTP头、超时时间等。 4. **开始请求**:调用`[request startAsynchronous]...

    ASIHttpRequest下载

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://example.com"]]; [request startAsynchronous]; ``` 对于POST请求,可以使用ASIFormDataRequest,并添加参数: ```...

    ASIHTTPRequest使用指南(中文版)

    - **示例代码**:通常通过`[ASIHTTPRequest requestWithURL:url synchronize:YES]`方法创建同步请求。 - **应用场景**:适合于数据量较小且对用户体验影响不大的场景。 ##### 2.2 创建一个异步请求 - **概念**:...

    ASIHTTPRequest 框架

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com"]]; [request startSynchronous]; ``` 2. **异步处理**:ASIHTTPRequest 支持异步请求,可以在后台...

    IOS构建网络连接,连接ws

    ASIHTTPRequest *theRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:requestUrl]]; [theRequest addRequestHeader:@"Content-Type" value:@"text/xml"]; [theRequest setRequestMethod:@"GET"]; ...

    ASI 表单提交

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://example.com/upload"]]; [request addData:UIImageJPEGRepresentation(image, 0.8) withName:@"photo" fileName:...

Global site tag (gtag.js) - Google Analytics