• 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: &xxx; thingies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: &xxx; thingies


  • Subject: Re: &xxx; thingies
  • From: Dan Wood <email@hidden>
  • Date: Sat, 17 Nov 2001 11:06:05 -0800

I use this trick to "flatten" HTML. It initializes an attributed string from HTML (which will convert the &xyz; stuff) and then you extract the plain string out of it. I think it's similar to what you're looking for; feel free to use it.

- (NSString *) flattenHTML
{
NSString *result = self;
NSAttributedString *attrString;
NSData *theData = [self dataUsingEncoding:NSMacOSRomanStringEncoding]; // encoding for below to work
if (nil != theData) // this returned nil once; not sure why; so handle this case.
{
attrString
= [[[NSAttributedString alloc]
initWithHTML:theData documentAttributes:nil] autorelease];
result = [attrString string];
}
return result;
}



On Friday, November 16, 2001, at 10:50 PM, Angela Brett wrote:

Hi,

I know I could do this myself but I'm sure it's already been done. What should I use to go through an NSString and turn the &amp; etc used in HTML into the characters they represent? It looks as if the Omniweb framework can do it, but I haven't figured out how yet. I don't really want to add all the Omni frameworks to my project just for that, so if someone could tell me about a simple way of doing it I'd be most grateful.
-- Angela Brett email@hidden http://acronyms.co.nz/angela
"Great minds think different."
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev



--
Dan Wood
email@hidden
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume: http://www.karelia.com/resume.html


References: 
 >&xxx; thingies (From: Angela Brett <email@hidden>)

  • Prev by Date: Re: Standard OS X Compression format
  • Next by Date: Re: Standard OS X Compression format
  • Previous by thread: Re: &xxx; thingies
  • Next by thread: Help with Variable Scope
  • Index(es):
    • Date
    • Thread