• 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: Heinrich Giesen <email@hidden>
  • Date: Tue, 19 Jul 2005 16:22:14 +0200


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


_______________________________________________ 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>
  • Prev by Date: Re: tooltip event/notification?
  • Next by Date: Re: tooltip event/notification?
  • Previous by thread: Scroll behavior at TextView bottom?
  • Next by thread: Re: Display Rich Text Encoding within plain text
  • Index(es):
    • Date
    • Thread