我正在开发一个应用程序,它在私人服务器上进行搜索并向用户显示结果。问题是 NSXLParser 无法解析特殊的德语和法语字符。例如:应该是:(Geschäftsführer)-> 我得到的是:(äftsführer)
我怎样才能解决这个问题 ?
这是我的代码:
- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
currentNodeContent = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementname isEqualToString:@"results"])
{
currentJob = [SearchResult alloc];
}
}
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementname isEqualToString:@"jobTitle"])
{
currentJob.jobTitle = currentNodeContent;
}
if ([elementname isEqualToString:@"location"])
{
currentJob.shortAddress = currentNodeContent;
}
if ([elementname isEqualToString:@"companyName"])
{
currentJob.employer = currentNodeContent;
}
if ([elementname isEqualToString:@"results"])
{
[self.jobs addObject:currentJob];
currentJob = nil;
currentNodeContent = nil;
}
}
任何帮助将不胜感激......提前致谢