• 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: Display Rich Text Encoding within plain text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Display Rich Text Encoding within plain text


  • Subject: Re: Display Rich Text Encoding within plain text
  • From: Aki Inoue <email@hidden>
  • Date: Tue, 19 Jul 2005 10:41:21 -0700

Note there is no guarantee that the RTF raw data doesn't have any binary attached (and it will fail in that case).
In that case, you might want to manually escape the bytes (i.e. 0x80 - > "\'80").


Aki

That works beautifully, thanks a million!



--- Heinrich Giesen <email@hidden>
wrote:



On 19.07.2005, at 04:28, Ian was here wrote:


The problem is that if I take the
rich text in a text view and move it to an

NSString,

then the rich text encoding is stripped away, and

the

plain text itself remains. I want to display all

the

gobbledeegook from the RTF.


try something like this (and change the code as you like): select something in your NSTextView and then use a button which has a connection to:

- (IBAction) showSelectedRTF:sender
{
     NSAttributedString *attrString = [textView
textStorage];
     NSRange range = [textView selectedRange];
     NSData *selectedData = [attrString
RTFFromRange:range
documentAttributes:NULL];
     NSString *dataString = [[NSString alloc]
initWithBytes:
[selectedData bytes]

length:
[selectedData length]

encoding:NSASCIIStringEncoding];

     NSLog( @"RTF data = \n%@\n", dataString ); //
or something else
}



For Japanese text it also works pretty well.


-- Heinrich Giesen email@hidden








____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs

 _______________________________________________
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: Display Rich Text Encoding within plain text
      • From: Ian was here <email@hidden>
References: 
 >Re: Display Rich Text Encoding within plain text (From: Ian was here <email@hidden>)

  • Prev by Date: Re: NSFileManager - "Can't read directory contents" ??
  • Next by Date: Custom ordered table - core data - array controller
  • Previous by thread: Re: Display Rich Text Encoding within plain text
  • Next by thread: Re: Display Rich Text Encoding within plain text
  • Index(es):
    • Date
    • Thread