• 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: NSString and decoding HTML Entities
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString and decoding HTML Entities


  • Subject: Re: NSString and decoding HTML Entities
  • From: "I. Savant" <email@hidden>
  • Date: Sun, 5 Apr 2009 17:32:55 -0400

On Apr 5, 2009, at 4:35 PM, Stuart Malin wrote:

The source is not HTML tagged, but contains HTML entities.

see:
http://www.w3schools.com/tags/ref_entities.asp
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references


So, for instance, I want to convert "--&gt;" to "-->"

No need for an attributed string.

Thanks, but I understand the difference perfectly, but it's irrelevant. HTML entities are HTML too, so this worked fine:


NSMutableAttributedString * aStr = [[NSMutableAttributedString alloc] initWithHTML:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"file:///Users/me/test.html "]] documentAttributes:nil];
[textView replaceCharactersInRange:NSMakeRange(0, [[textView string] length]) withString:[aStr string]];


... with an HTML file containing the entity &gt (NSData from local file for convenient illustrative purposes) but your method is probably more direct / efficient. I referenced the above because you said, "I can't seem to find an NSString method to do so (not that I sometimes don't easily miss the obvious)."

  It's not strictly NSString, but might have worked fine for you.

--
I.S.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: NSString and decoding HTML Entities
      • From: Stuart Malin <email@hidden>
References: 
 >NSString and decoding HTML Entities (From: Stuart Malin <email@hidden>)
 >Re: NSString and decoding HTML Entities (From: "I. Savant" <email@hidden>)
 >Re: NSString and decoding HTML Entities (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: IB Plugin help
  • Next by Date: Newbie question: Cocoa threads within RubyCocoa
  • Previous by thread: Re: NSString and decoding HTML Entities
  • Next by thread: Re: NSString and decoding HTML Entities
  • Index(es):
    • Date
    • Thread