NSXMLParser encoding error

2019-08-18 05:53发布

问题:

I'm programming an application using latin characters. Here are the lines I use to get data by XML parsing.

NSURL *url = [NSURL URLWithString:urlString]; // urlString : param of the function
NSData *data = [NSData dataWithContentsOfURL:url];
parser = [[NSXMLParser alloc] initWithData:data];

But for example, œ or ' are replaced by ¿. So what should I do ?

The encoding of my xml file :

<?xml version="1.0" encoding="ISO8859-1"?>

Thanks for your advices

回答1:

You can try this:

œ ==> &oelig; and for ' ==> &apos;

if you need more characters use this:

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references