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 <cejw...@gmail.com 
> > (mailto:cejw...@gmail.com)> 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 (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

Reply via email to