当我 NSLog HTTP 请求响应字符串时,它显示为“ãÃÂïãÃâ¬ÃÂãÃÂÃÂãÔ,并且 UILabel 上出现了一些不同的内容,但与我期望的日文/中文格式不同。我正在使用 ASIHTTPRequest 并且如前所述,我已将响应编码设置为 NSUTF8StringEncoding(服务器使用 UTF-8 相同),但它没有帮助。有人可以告诉我如何在我的应用程序中支持 unicode 字符吗?谢谢。
- (void)getData
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[dataUrl stringByAppendingFormat:@"%@",self.selectedID]]];
[request setResponseEncoding:NSUTF8StringEncoding];
SBJSON *parser = [[SBJSON alloc] init];
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithCapacity:3];
[data setObject:self.username forKey:@"username"];
[data setObject:self.password forKey:@"password"];
NSString *dataJSON = [parser stringWithFragment:data error:nil];
[request appendPostData:[dataJSON dataUsingEncoding:NSUTF8StringEncoding]];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestSuccess:)];
[request setDidFailSelector:@selector(requestFailed:)];
[self.queue addOperation: request];
[self.queue go];
}
- (void)requestSuccess:(ASIHTTPRequest *)request
{
NSLog(@"success: %@", [request responseString]);
}