Re: Am I Reinventing the Wheel? (Part I)
Re: Am I Reinventing the Wheel? (Part I)
- Subject: Re: Am I Reinventing the Wheel? (Part I)
- From: Charles Jenkins <email@hidden>
- Date: Fri, 09 Jan 2015 00:29:18 -0500
Jens is right, and I was quite mistaken. The disaster wasn’t a problem with XMLParser’s deserialization at all.
When writing out my paragraphs, I create one <p> node for each and put the full paragraph text in. My mistake was believing XMLParser would operate the same way, reading the full text of the <p> node at once. So every time my delegate’s parser:foundCharacters: was called, I treated the delivered string as a full paragraph and added newlines.
In fact, parser:foundCharacters: may be called repeatedly to deliver paragraph text in chunks. In my case, ampersands and curled quotes were delivered in their own chunks, and it was me botching the result up by inserting extraneous newlines. I have no excuse, because Apple’s documentation says three times that the string received by parser:foundCharacters: may be incomplete.
—
Charles Jenkins
On Thursday, January 8, 2015 at 12:30 PM, Jens Alfke wrote:
>
> > On Jan 8, 2015, at 4:43 AM, Charles Jenkins <email@hidden (mailto:email@hidden)> wrote:
> > I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster!
> No, it's fine for XML text to contain non-ASCII Unicode characters.
>
> —Jens
_______________________________________________
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