如何从XML中删除变音符号?

时间:2010-01-20 05:24:23

标签: iphone objective-c xml character-encoding diacritics

我试图从XML中删除umlaults.i也使用了一些像这样的代码,但它仍然没有用,所以请帮助我完成任务。

NSString *something  = [self base64StringFromData:CDATABlock length:[CDATABlock  length]];   
NSData *pageData=[something dataUsingEncoding:NSUTF8StringEncoding];
NSString *webpage = [NSString stringWithCString:something encoding:NSUTF8StringEncoding];
NSString *torrent = [NSString stringWithUTF8String:something];
NSString *body = [NSString stringWithCString:[CDATABlock bytes] length:[CDATABlock length] encoding:NSUTF8StringEncoding];
NSData *torrent = [ objectFromEncodedData:CDATABlock];
NSString *secondtry = [NSString stringWithFormat:@"%.*s", [CDATABlock length], [CDATABlock bytes]];
NSString *secondtry = [[NSString alloc] initWithBytes:[CDATABlock bytes]length:[CDATABlock length] encoding: NSUTF8StringEncoding];
NSString *secondtry = [NSString stringWithCString:[CDATABlock bytes] encoding:NSUTF8StringEncoding];
NSString *secondtry = [NSString stringWithUTF8String:[CDATABlock bytes]];
NSString *secondtry = [NSString stringWithCharacters:[CDATABlock bytes] length:[CDATABlock length] / sizeof(unichar)];

实际上从XML我得到了这个标签

[CDATA[Dickensstraße, Zoo, Mitte (Stadtbezirk), Hannover, Region Hannover, 30175, Niedersachsen, Deutschland]]

并显示此标记,以便我在显示中出现错误的字符串。

DickensstraÃe, Zoo, Mitte (Stadtbezirk), Hannover, Region Hannover, 30175, Niedersachsen, Deutschland

1 个答案:

答案 0 :(得分:0)

你必须弄清楚用什么编码将文本放在CDATA块中,并对你得到的数据使用相同的编码。

虽然我不得不说,如果有任何办法不将文本包装在CDATA块中,我会这样做。这是一种可怕的滥用XML,它可以很好地处理unicode ......