Parsing ISO-8859-1 w/ NSXmlParser
- by Travis
I am usin the nsxmlparser and am wondering how I can parse ISO-8859-1 correctly into an NSString.
Currently, I am getting results w/ Â for two-byte characters.
The XML I'm using (not created by me) starts with <?xml version="1.0" encoding="ISO-8859-1"?>
Here are the basic calls I'm using (omitted the NSThread calls).
NSString *xmlFilePath = [[NSBundle mainBundle] pathForResource:sampleFileName ofType:@"xml"];
NSString *xmlFileContents = [NSString stringWithContentsOfFile:xmlFilePath encoding:NSUTF8StringEncoding error:nil];
NSData *data = [xmlFileContents dataUsingEncoding:NSUTF8StringEncoding];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
[parser setDelegate:self];
[parser parse];