• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: string of rich text (rtf) tags to rtfData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: string of rich text (rtf) tags to rtfData
      • From: Richard Salvatierra <email@hidden>
References: 
 >string of rich text (rtf) tags to rtfData (From: Richard Salvatierra <email@hidden>)

  • Prev by Date: Re: Regarding iTunes 7 sidebar
  • Next by Date: NSPanel shown as sheet comes up partially transparent
  • Previous by thread: string of rich text (rtf) tags to rtfData
  • Next by thread: Re: string of rich text (rtf) tags to rtfData
  • Index(es):
    • Date
    • Thread