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 > <diede...@tenhorses.com> 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 (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com > > This email sent to garyw...@desisoftsystems.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com