Re: Reading in UTF-8 to Data
The XML file is from an app I wrote a long time ago and contains thousands of documents similar to this one. Once Nick mentioned quotable-printable I remembered I used that. It was so long ago I had forgotten. There are many users that use the app and each of them have hundreds, if not thousands, of individual XML files and they need this functionality. My last resort would be to send out update for the old app to all the users to reprocess their XML files w/o the quoted-printable but you know how that will go. If I could only get Cocoa to do it I'd be done. On Jul 15, 2010, at 9:20 PM, Greg Guerin wrote: Brad Stone wrote: Yes, quoted-printable. That's precisely it but in doing my research in the documentation and on the internet it doesn't seem like it's a simple process especially for someone like me with 9 months of Cocoa development experience. There is nothing apparent in your code that would cause quoted-printable to magically appear. If it's not your code, the next most obvious candidate is your data. Exactly where is your data coming from, and exactly how did it get there? Maybe you have a glitch somewhere along your data-production pathway, that's unexpectedly producing quoted-printable. That pathway includes all uploads, file-transfers, file copies, etc. It even includes any editor you used the last time you looked at the original XML file. If the editor is helping you by interpreting quoted-printable, then you might want to try something simpler, like the 'cat' command in Terminal.app, or even the 'hexdump -C' command. If you're not a Terminal person, HexFiend is your friend (google it). -- GG ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com This email sent to cocoa-...@softraph.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
On Fri, Jul 16, 2010 at 5:58 AM, Brad Stone cocoa-...@softraph.com wrote: The XML file is from an app I wrote a long time ago and contains thousands of documents similar to this one. Once Nick mentioned quotable-printable I remembered I used that. It was so long ago I had forgotten. There are many users that use the app and each of them have hundreds, if not thousands, of individual XML files and they need this functionality. My last resort would be to send out update for the old app to all the users to reprocess their XML files w/o the quoted-printable but you know how that will go. If I could only get Cocoa to do it I'd be done. The framework knows nothing about your file format, so you can't get Cocoa to do it. You'll simply need to perform the conversion yourself when you read the file in from disk. --Kyle Sluder ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
Kyle - I have my legacy file format perfectly parsed into an NSDictionary and my code works fine from the NSOpenPanel to select the legacy document to creating the new document in Cocoa, adding it to the managedObjectContext, inserting the data in all the right places and saving the new document. The process would be perfect if I could decode the quoted-printable text in Cocoa. That's the only thing that's still incomplete. What I meant when I said Cocoa to do it was that I would like to decode in Cocoa versus having to create additional code in the legacy app to create a new file format w/o the quoted-printable encoding. Hopefully that's a clearer explanation. Does anyone have any code snippets they can share that will decode quoted-printable? On Jul 16, 2010, at 11:31 AM, Kyle Sluder wrote: On Fri, Jul 16, 2010 at 5:58 AM, Brad Stone cocoa-...@softraph.com wrote: The XML file is from an app I wrote a long time ago and contains thousands of documents similar to this one. Once Nick mentioned quotable-printable I remembered I used that. It was so long ago I had forgotten. There are many users that use the app and each of them have hundreds, if not thousands, of individual XML files and they need this functionality. My last resort would be to send out update for the old app to all the users to reprocess their XML files w/o the quoted-printable but you know how that will go. If I could only get Cocoa to do it I'd be done. The framework knows nothing about your file format, so you can't get Cocoa to do it. You'll simply need to perform the conversion yourself when you read the file in from disk. --Kyle Sluder ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
Am 16.07.2010 um 14:58 schrieb Brad Stone: The XML file is from an app I wrote a long time ago and contains thousands of documents similar to this one. Once Nick mentioned quotable-printable I remembered I used that. It was so long ago I had forgotten. There are many users that use the app and each of them have hundreds, if not thousands, of individual XML files and they need this functionality. My last resort would be to send out update for the old app to all the users to reprocess their XML files w/o the quoted-printable but you know how that will go. If I could only get Cocoa to do it I'd be done. Run, don't walk, and find some code snippet that removes the bizarre QP reencoding from the data you get reading your XML, and don't reapply it saving (except in a backward compatibility mode for non-upgrading users). The whole idea of UTF-8 is to be able to represent about any glyph imaginable without requiring reencoding, and UTF8-encoded XML deals pretty well with it besides the requirement to escape ' under certain circumstances.___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
Agreed Thomas but code snippets have been elusive. On Jul 16, 2010, at 1:00 PM, Thomas Engelmeier wrote: Am 16.07.2010 um 14:58 schrieb Brad Stone: The XML file is from an app I wrote a long time ago and contains thousands of documents similar to this one. Once Nick mentioned quotable-printable I remembered I used that. It was so long ago I had forgotten. There are many users that use the app and each of them have hundreds, if not thousands, of individual XML files and they need this functionality. My last resort would be to send out update for the old app to all the users to reprocess their XML files w/o the quoted-printable but you know how that will go. If I could only get Cocoa to do it I'd be done. Run, don't walk, and find some code snippet that removes the bizarre QP reencoding from the data you get reading your XML, and don't reapply it saving (except in a backward compatibility mode for non-upgrading users). The whole idea of UTF-8 is to be able to represent about any glyph imaginable without requiring reencoding, and UTF8-encoded XML deals pretty well with it besides the requirement to escape ' under certain circumstances.___ 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: http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com This email sent to cocoa-...@softraph.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
In the first page of Google hits for nsstring quoted-printable http://stackoverflow.com/questions/491678/can-you-translate-php-function-quoted-printable-decode-to-an-nsstring-based-ob This is at least a starting point. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
I was all over the internet last night including Stack Overflow, Coco Dev, this mailing list. I can' t believe I missed this. Thanks! On Jul 16, 2010, at 2:58 PM, Kirk Kerekes wrote: In the first page of Google hits for nsstring quoted-printable http://stackoverflow.com/questions/491678/can-you-translate-php-function-quoted-printable-decode-to-an-nsstring-based-ob This is at least a starting point. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Reading in UTF-8 to Data
I'm having trouble getting text to appear properly in an NSTextView which is binded to an NSData attribute in core data. I've been all over the internet but I'm still stumped. The original text looks like this: There is a period at the end of this sentence. You should have also just seen a line return and here • is a option-8 bullet character. This text is saved in an XML file that starts with ?xml version=1.0 encoding=UTF-8? My goal is to write code to read this XML file and create an NSData object for the text. This is what I've written: NSString *s = [childNode stringValue]; //assume this child is the correct text NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:YES]; // I also tried NSUTF8StringEncoding This results in the following appearing in my NSTextView There is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E I'd like to do the correct encoding but there's something wrong and I don't want to resort to the find and replace method. (i.e. find =2E and replace with .) The actual text in the XML file is: NoteThere is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E/Note (why there's an = between the s and t in the word just is confusing). Can anyone help? Thank you ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
On Jul 15, 2010, at 4:03 PM, Brad Stone wrote: I'm having trouble getting text to appear properly in an NSTextView which is binded to an NSData attribute in core data. I've been all over the internet but I'm still stumped. The original text looks like this: There is a period at the end of this sentence. You should have also just seen a line return and here • is a option-8 bullet character. This text is saved in an XML file that starts with ?xml version=1.0 encoding=UTF-8? My goal is to write code to read this XML file and create an NSData object for the text. This is what I've written: NSString *s = [childNode stringValue]; //assume this child is the correct text NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:YES]; // I also tried NSUTF8StringEncoding This results in the following appearing in my NSTextView There is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E I'd like to do the correct encoding but there's something wrong and I don't want to resort to the find and replace method. (i.e. find =2E and replace with .) The actual text in the XML file is: NoteThere is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E/Note (why there's an = between the s and t in the word just is confusing). Can anyone help? Looks like you need to translate the text in the XML file using a MIME quoted-printable decoder, and then run the results through a UTF-8 decoder. Quoted-printable sequences start with a = and the next two characters indicate the hex value of the character. For example, 0xe280a2 is the bullet character (U+2022) in UTF-8. See RFC 2045 for more details. Nick Zitzmann http://www.chronosnet.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
Yes, quoted-printable. That's precisely it but in doing my research in the documentation and on the internet it doesn't seem like it's a simple process especially for someone like me with 9 months of Cocoa development experience. Does anyone have a utility or sample code? On Jul 15, 2010, at 6:19 PM, Nick Zitzmann wrote: On Jul 15, 2010, at 4:03 PM, Brad Stone wrote: I'm having trouble getting text to appear properly in an NSTextView which is binded to an NSData attribute in core data. I've been all over the internet but I'm still stumped. The original text looks like this: There is a period at the end of this sentence. You should have also just seen a line return and here • is a option-8 bullet character. This text is saved in an XML file that starts with ?xml version=1.0 encoding=UTF-8? My goal is to write code to read this XML file and create an NSData object for the text. This is what I've written: NSString *s = [childNode stringValue]; //assume this child is the correct text NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:YES]; // I also tried NSUTF8StringEncoding This results in the following appearing in my NSTextView There is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E I'd like to do the correct encoding but there's something wrong and I don't want to resort to the find and replace method. (i.e. find =2E and replace with .) The actual text in the XML file is: NoteThere is a period at the end of this sentence=2E=0DYou should have also jus= t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E/Note (why there's an = between the s and t in the word just is confusing). Can anyone help? Looks like you need to translate the text in the XML file using a MIME quoted-printable decoder, and then run the results through a UTF-8 decoder. Quoted-printable sequences start with a = and the next two characters indicate the hex value of the character. For example, 0xe280a2 is the bullet character (U+2022) in UTF-8. See RFC 2045 for more details. Nick Zitzmann http://www.chronosnet.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in UTF-8 to Data
Brad Stone wrote: Yes, quoted-printable. That's precisely it but in doing my research in the documentation and on the internet it doesn't seem like it's a simple process especially for someone like me with 9 months of Cocoa development experience. There is nothing apparent in your code that would cause quoted- printable to magically appear. If it's not your code, the next most obvious candidate is your data. Exactly where is your data coming from, and exactly how did it get there? Maybe you have a glitch somewhere along your data-production pathway, that's unexpectedly producing quoted-printable. That pathway includes all uploads, file-transfers, file copies, etc. It even includes any editor you used the last time you looked at the original XML file. If the editor is helping you by interpreting quoted-printable, then you might want to try something simpler, like the 'cat' command in Terminal.app, or even the 'hexdump -C' command. If you're not a Terminal person, HexFiend is your friend (google it). -- GG ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com