Re: Trouble getting ISO-8859-1 encoded feed to parse and display
Re: Trouble getting ISO-8859-1 encoded feed to parse and display
- Subject: Re: Trouble getting ISO-8859-1 encoded feed to parse and display
- From: "Gary L. Wade" <email@hidden>
- Date: Sun, 23 Nov 2014 13:45:30 -0800
First, be sure the content in the XML document you're getting back matches the encoding in the header. If it doesn't and you have no control over the creation of it, you'll have to figure out the character set yourself. There's also some methods in NSString that will try to figure out that for you and return that. Secondly, ISO-8859-1 and UTF-8 are not equivalent.
--
Gary L. Wade (Sent from my iPad)
http://www.garywade.com/
> On Nov 23, 2014, at 1:06 PM, Diederik Meijer | Ten Horses <email@hidden> wrote:
>
> Hi list,
>
> I am having trouble getting useful data from this url on some, but not all, iOS devices: https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml
>
> The feed has this opening tag: <?xml version="1.0" encoding="ISO-8859-1" ?>
>
> When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices.
>
> When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work.
>
> NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSUTF8StringEncoding];
>
>
> Still, in that case, some devices will show the parsed feed, some won’t.
>
> I tried converting the data into NSISOLatin1 and then putting it back into NSData using UTF8, as below, but that doesn’t help.
>
> -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
> NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSISOLatin1StringEncoding];
> [self setDataContainer:[[dataString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]];
> self.xmlItems = [NSMutableArray array];
> NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.dataContainer];
> [parser setDelegate:self];
> [parser parse];
> }
>
>
> I validated the feed’s XML and got no errors..
>
> Anybody out there with experience in solving this?
>
>
> Many thanks!
>
>
>
> Diederik
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden