Re: using fileWrapperFromRange: for lossy conversion
Re: using fileWrapperFromRange: for lossy conversion
- Subject: Re: using fileWrapperFromRange: for lossy conversion
- From: Douglas Davidson <email@hidden>
- Date: Wed, 20 May 2009 11:22:17 -0700
On May 20, 2009, at 11:01 AM, Philip White wrote:
Sorry for the vagueness. The NSError object return by the routine
has a description of
"Error Domain=NSCocoaErrorDomain Code=517 UserInfo=0x53586b0 "The
file could not be saved using text encoding Western (Mac OS Roman)."
I've noticed that I don't get errors saving an RTF file even if it
means a loss of attachments. Also, I have to double check on this,
but I think that only attachments and not other attributes make a
save to plain text fail.
Attachments are stored in the text as an NSAttachmentCharacter (U
+FFFC, the Unicode replacement character) with an
NSAttachmentAttributeName attribute consisting of an
NSTextAttachment. Your problem here is not with the attribute, but
with the character--it can't be stored in the encoding you're using,
Mac Roman. If you use a Unicode encoding like UTF-8, then you will be
able to represent these characters, and there are good reasons for
using Unicode encodings if you have any choice in the matter.
However, you may also want to consider whether you want the attachment
characters in your text at all--they aren't terribly meaningful in
plain text, without their attachments. If you want to strip them out,
you can take a look at the source code for TextEdit, which removes
attachments when converting documents to plain text.
Douglas Davidson
_______________________________________________
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