Question

I am fetching data from URL, and this data contains special characters, such as in the name Désirée.

I want to display this in my TableView cell, but when I display it, it looks like this: Dösiröe.

How do I make it display correctly?

Fetch data

NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL] encoding: NSStringEncodingConversionAllowLossy error:nil];
SBJSON *parser = [[SBJSON alloc] init];
dictShow = [parser objectWithString:jsonString error:nil];
arr=[dictShow copy];

Display Data in TableView

cell.textLabel.text = [arr objectAtIndex:indexPath.row];
Was it helpful?

Solution

just use NSUTF8StringEncoding instead of NSStringEncodingConversionAllowLossy like....

NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL] encoding:NSStringEncodingConversionAllowLossy error:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top