Re: Converting NSString to valid HTML string
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 < 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