• 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: Converting NSString to valid HTML string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting NSString to valid HTML string


  • Subject: Re: Converting NSString to valid HTML string
  • From: Nate Weaver <email@hidden>
  • Date: Thu, 21 Aug 2008 13:45:57 -0500

Those are for URL encoding; I think he wants HTML entities. I can't remember if there are Cocoa methods to do this, but you can use CFXMLCreateStringByEscapingEntities() (since NSString * and CFStringRef are toll-free bridged):

NSString *input = @"2 < 4";
NSString *output = (NSString *)CFXMLCreateStringByEscapingEntities(NULL, (CFStringRef)input, NULL);


Should result in output being @"2 &lt; 4".

Just remember that the output string will need to be released.

On Aug 21, 2008, at 1:32 PM, Randall Meadows wrote:

On Aug 21, 2008, at 12:16 PM, JanakiRam wrote:

I'm developing an Cocoa client application.As part of application logic , i
make the Webservice Call with XML data - which returns the XML file as
response which contains the HTML code for the special characters. While
sending the data i need to convert the special characters such as &,'
etc.... with their HTML Codes/equivalents and also need to extract the
string by replacing the HTML codes while retrieving the data. Can any one
suggest me the preferred way to convert/extract HTML Codes.

Take a look at the NSString documentation, the "Working with URLs" section:


– stringByAddingPercentEscapesUsingEncoding:
– stringByReplacingPercentEscapesUsingEncoding:

_______________________________________________

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


_______________________________________________

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


References: 
 >Converting NSString to valid HTML string (From: JanakiRam <email@hidden>)
 >Re: Converting NSString to valid HTML string (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: !foo vs foo == nil
  • Next by Date: Re: !foo vs foo == nil
  • Previous by thread: Re: Converting NSString to valid HTML string
  • Next by thread: Parsing any date/time format with NSDateFomatter
  • Index(es):
    • Date
    • Thread