• 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: RS: NSString from RTF file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RS: NSString from RTF file


  • Subject: Re: RS: NSString from RTF file
  • From: glenn andreas <email@hidden>
  • Date: Mon, 4 Jun 2007 09:14:11 -0500


On Jun 4, 2007, at 9:01 AM, Roland Silver wrote:

Can anyone suggest Cocoa code to (1) read an RTF file; (2) create an NSString containing the contents of that file, devoid of the attributes?

For example, I have a short test file whose content, converted to a string by initWithData:data encoding:NSISOLatin1StringEncoding, looks like this:

{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\froman\fcharset77 TimesNewRomanMS;\f1\froman \fcharset77 TimesNewRomanItMS;}
{\colortbl;\red255\green255\blue255;\red255\green0\blue0;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab720
\pard\pardeftab720\sa360\qj


\f0\fs37\fsmilli18667 \cf0 Arma \cf2 virumque\cf0 cano, Troiae qui
\f1\i primus
\f0\i0 ab oris\uc0\u8232 Italiam, fato profugus, Laviniaque venit \u8232 }


So: can you suggest a code fragment to convert that (or any similar attributed string) to the NSString

@"Arma virumque cano, Troiae qui primus ab oris
Italiam, fato profugus, Laviniaque venit"?



NSString *unformattedText = [[[[NSAttributedString alloc] initWithPath: filepath documentAttributes: nil] autorelease] string];



Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build, mutate, evolve, animate




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: RS: NSString from RTF file
      • From: Robert Walker <email@hidden>
References: 
 >RS: NSString from RTF file (From: Roland Silver <email@hidden>)

  • Prev by Date: Re: RS: NSString from RTF file
  • Next by Date: Re: How to determine if any intermediate directory in path is link?
  • Previous by thread: Re: RS: NSString from RTF file
  • Next by thread: Re: RS: NSString from RTF file
  • Index(es):
    • Date
    • Thread