Parsing ISO-8859-1 w/ NSXmlParser
Posted
by Travis
on Stack Overflow
See other posts from Stack Overflow
or by Travis
Published on 2010-03-21T00:22:44Z
Indexed on
2010/03/21
3:31 UTC
Read the original article
Hit count: 801
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];
© Stack Overflow or respective owner