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];
just use NSUTF8StringEncoding instead
of NSStringEncodingConversionAllowLossy
like....
NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL] encoding:NSStringEncodingConversionAllowLossy error:nil];
来源:https://stackoverflow.com/questions/16166176/dealing-with-special-characters-like-%c3%b6-%c3%84-%c3%a9-%c3%9f-in-ios