What is the right way to trim characters in foundCharacters
of NSXMLParser
?
I've found many examples that do it like this:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
NSString *characters = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// Append to previous characters of the same element
}
Yet a space followed by a non-ASCII character is trimmed when I run the above. Example: "this é" will become "thisé".
This is what I've used in the past to trim whitespace without any problems.
The only difference is that It's using a slightly different whitespace character set.