I'm reading in a validated XML  file via NSXMLParser and things work
very well except when it comes to elements that contain "foreign"
charcters such as ß, ü, ä, etc. For example, i have an element like
so:

<g:name>Großefehn-4 - Großefehnkanal</g:name>

I want to extract the contents, "Großefehn-4 - Großefehnkanal", into a
string, but all I end up with is "ßefehn-4 - Großefehnkanal" with
everything else cut off.

I'm using the following:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString
*)elementName namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName attributes:(NSDictionary
*)attributeDict
{
       if ([elementName isEqualToString:@"g:name"]) {
               NSLog(@"Found Name Element");
       }
}

and

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
       if (!currentValue) {
               currentValue = [[NSMutableString alloc] init];
       }
       NSLog(@"String: %@",string);
       [currentValue setString:string];
}

and

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString
*)elementName namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
       if ( [elementName isEqualToString:@"g:name"] ) {
               [gNames addObject:[NSString stringWithString:currentValue]];
       }
}

What happens is that gNames ends up with the truncated string value.
The output of NSLog, though, shows:
2009-02-01 12:45:09.538 [320:10b] String: Gro
2009-02-01 12:45:09.538 [320:10b] String: ßefehn-4 - Großefehnkanal

I'm also adding these strings to an array, and the array for this
particular entry shows:
\U00dfefehn-4 - Gro\U00dfefehnkanal

So for some reason, it's breaking up those strings into seperate
lines, and I can't figure out why. The only thing I can figure is that
it has to do with the encoding, but the XML document is UTF-8. Any
insight is much appreciated.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to