Closed cliffjoyce closed 13 years ago
Update: I actually found a quick workaround solution. I checked out a fresh copy of the Google Toolbox from this page:
http://code.google.com/p/google-toolbox-for-mac/
Then I added this code to your NSString+HTML class:
#import "GTMNSString+XML.h"
// Encode all XML entities using GTM
- (NSString *)stringByEncodingXMLEntities {
return [NSString stringWithString:[self gtm_stringBySanitizingAndEscapingForXML]];
}
Also, it turns out that I was mistaken about one thing: only the 5 entities above need to be escaped. Other unicode chars evidently don't need any escaping at all. The nice thing about the Google gtm_stringBySanitizingAndEscapingForXML call is that it will also remove any illegal chars.
Glad you sorted it out! :-)
I realize that "NSString+XMLEntities" is depreciated (replaced by "NSString+HTML").
However, "NSString+HTML" stringByEncodingHTMLEntities is not suitable for encoding entities for use in XML. The reason is that XML apparently only permits these 5 keyword mapped entities:
For XML, all other entities must apparently be mapped to the appropriate xx; value. Example character: Ø. The Ø needs to instead be Ø or other XML parsers barf.
Do you know of a quick workaround? Thanks!