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: Richard Salvatierra <email@hidden>
- Date: Wed, 25 Oct 2006 09:09:49 -0400
This is working fine. Does anyone see and issues (All string data
will have come from a mac);
NSData *data = [aString dataUsingEncoding: NSMacOSRomanStringEncoding]
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
}
On Oct 25, 2006, at 3:09 AM, Fredrik Olsson wrote:
Richard Salvatierra skrev:
How do I convert a string of rtf tags to an NSData object?
My string looks like this:
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;\red255\green0\blue12;\red51
\green204\blue255;\red7\green255\blue0;
}
\vieww12000\viewh15840\viewkind0
\deftab720
\pard\pardeftab720\qc
\f0\fs120 \cf2 This\cf1 \cf3 is a\cf1 \cf4 Test}
I assume you have your RTF-string in NSString *rtfString.
NSData *rtfData = [rtfString
dataUsingEncoding:NSWindowsCP1252StringEncoding];
And then maybe?:
NSAttributedString *attributedString = [[NSAttributedString alloc]
initWithRTF:rtfData documentAttributes:nil];
// Fredrik Olsson
-Rich
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40kmstudio.se
This email sent to email@hidden
_______________________________________________
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