Re: string of rich text (rtf) tags to rtfData
Re: string of rich text (rtf) tags to rtfData
- Subject: Re: string of rich text (rtf) tags to rtfData
- From: Douglas Davidson <email@hidden>
- Date: Wed, 25 Oct 2006 12:06:17 -0700
On Oct 25, 2006, at 6:09 AM, Richard Salvatierra wrote:
This is working fine. Does anyone see and issues (All string data
will have come from a mac);
NSData *data = [aString dataUsingEncoding: NSMacOSRomanStringEncoding]
The basic problem with this sort of thing is that RTF contents are
not really a string, because they do not have a well-defined
encoding. It is better never to put the RTF data into an NSString in
the first place, rather than to try to figure out how to get them in
and out. Picking an encoding will more or less work, but not
necessarily for all text. We try to handle RTF contents as NSData
everywhere, for just this reason. Look for the point at which your
RTF gets into an NSString, and try changing that to NSData.
One other question: To test for the presence of an rtf commented
string I do the following. What is a better way?
NSRange rtfRange = [aString rangeOfString: @"rtf1"];
if(NSNotFound != rtfRange.location){
// rich text
}
We usually look for the 5 bytes "{\\rtf" to detect RTF data. If you
use NSAttributedString methods and do not specify the type of the
document you are importing, NSAttributedString will automatically
detect RTF along with many other formats.
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden