I have an iOS 7 app that is calling a webservice that returns XML with encoded characters. At first there was only a few of them, so I was just replacing them like so:
- (NSString *)convertEncodedCharacters:(NSString *)html
{
// Handle escape characters
html = [html stringByReplacingOccurrencesOfString:@"’" withString:@"'"];
html = [html stringByReplacingOccurrencesOfString:@"‘" withString:@"‘"];
html = [html stringByReplacingOccurrencesOfString:@"—" withString:@"-"];
html = [html stringByReplacingOccurrencesOfString:@""" withString:@"\""];
html = [html stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
html = [html stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
html = [html stringByReplacingOccurrencesOfString:@">" withString:@">"];
html = [html stringByReplacingOccurrencesOfString:@"–" withString:@"–"];
html = [html stringByReplacingOccurrencesOfString:@"“" withString:@"“"];
html = [html stringByReplacingOccurrencesOfString:@"”" withString:@"”"];
html = [html stringByReplacingOccurrencesOfString:@"‚" withString:@"‚"];
html = [html stringByReplacingOccurrencesOfString:@" " withString:@" "];
return html;
}
But now the content has gotten more complex and I keep running into new characters. Is there a way to just convert all of the encoded characters into human readable ones?