我有一些文本在 UITextView 中没有正确显示。“é”、“ç”和“ñ”等...都显示如下:
文本来自服务器,在 Web 浏览器中查看时显示良好。
想知道如何解决这个问题。谢谢你的帮助。
这是代码:
// the deal id is passed from the offersvc table selected item and into the url
// dealID is 1020414
NSString *jsonDealString = [NSString stringWithFormat:@"http://api.**********.net/v1/public/details?id=%@&yd.key=******", dealId];
NSLog(@"jsondealstring is %@", jsonDealString);
// NSLog(@"deal id is %@",dealId);
// Download JSON
NSString *jsonString = [NSString
stringWithContentsOfURL:[NSURL URLWithString:jsonDealString]
encoding:NSStringEncodingConversionAllowLossy
error:nil];
// Create parser for the api
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *results = [parser objectWithString:jsonString error:nil];
[self setDisplayItems:[results objectForKey:@"results"]];
NSDictionary *item = (NSDictionary *)[displayItems objectAtIndex:0];
// NSLog(@"item from details is %@", item);
// set the labels and text views.
link = [item objectForKey:@"link"];
catStr = [item objectForKey:@"cat"];
vendorStr = [item objectForKey:@"vendor"];
titleStr = [item objectForKey:@"main_tag"];