Re: Normalizing text in elements from NSXMLParser
Re: Normalizing text in elements from NSXMLParser
- Subject: Re: Normalizing text in elements from NSXMLParser
- From: Jerry Krinock <email@hidden>
- Date: Sat, 19 Dec 2009 06:11:57 -0800
On 2009 Dec 19, at 05:50, Charles Burnstagger wrote:
> I retrieve some text from elements found in XML I parse using NSXMLParser on iPhone. The text contains special characters such as #x92;s instead of 's.
>
> I've tried all the normalization routines on NSString but none of them work on the special characters. Is there anyway in Cocoa to directly fix such special characters or do I need to write my own mapping routine?
There's a function in Core Foundation. Here's what I use, in an NSString category
- (NSString *)stringByDecodingXMLEntities {
NSString *unescapedString = (NSString *)CFXMLCreateStringByUnescapingEntities(
NULL,
(CFStringRef)self,
NULL);
// Apple documentation for the above function is very confusing regarding what the
// last argument does. I tried several examples. It seems to always replace
// something of the form &#dd; where dd is 1-3 decimal digits, regardless
// of what the last argument is. I have never seen any effect from the last argument.
return [unescapedString autorelease];
}
Interesting comment I wrote four years ago. Let us know if you figure out what the last argument does._______________________________________________
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