Re: &xxx; thingies
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 & 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