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: Fredrik Olsson <email@hidden>
- Date: Wed, 25 Oct 2006 09:09:17 +0200
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:
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