伙计们,我已经尝试过所有并且没有成功。
创建
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:self.urlString]];
request.delegate = self;
[request setDefaultResponseEncoding:NSUTF8StringEncoding];
[request setResponseEncoding:NSUTF8StringEncoding];
[request setRequestMethod:@"PUT"];
[request addRequestHeader:@"Accept" value:@"application/xml"];
[request addRequestHeader:@"Content-Type" value:@"application/xml; charset=UTF-8;"];
Desplaying:
- (void)requestFinished:(ASIHTTPRequest *)request
{
[self HideProgressing];
// NSString *poweredBy = [[request responseHeaders] objectForKey:@"X-Powered-By"];
// NSString *contentType = [[request responseHeaders] objectForKey:@"Content-Type"];
NSString *body = [request responseString];
//NSString *body = [[NSString alloc] initWithData:[request responseData] encoding:NSUTF8StringEncoding];
NSLog(@"%@\n%@", body, request.responseStatusMessage);
甚至“内容类型”表示它具有UTF-8。但我只看到像“&#4857”这样的东西而不是西里尔符号。
有人用编码解决了同样的问题吗?
数据来自Basecamp API,如果有帮助的话。感谢。
答案 0 :(得分:0)
这是一个HTML编码/解码问题。注意,URL编码/解码是不同的。
为西里尔文编码/解码表 - http://webdesign.about.com/od/localization/l/blhtmlcodes-ru.htm
代码方法: http://code.google.com/p/statz/source/browse/trunk/NSString%2BHTML.h http://code.google.com/p/statz/source/browse/trunk/NSString%2BHTML.m
或者这一个:https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/GTMNSString%2BHTML.m
我还没有实现,现在还有其他任务。
祝你好运。