我从服务器数据获取UTF8编码数据就像Less%20than%20100
但我需要Less than 100
(解码格式)中的数据,我的NSXMLParsing委托方法就像
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"option"]) {
dict = [[NSMutableDictionary alloc]init];
[dict setValue:[attributeDict objectForKey:@"text"] forKey:@"text"];/* Here itself i need to decode & save in to my dict */
}
如何解码此数据。
答案 0 :(得分:5)
解码xml后,在stringByReplacingPercentEscapesUsingEncoding:
上使用NSString
方法:
NSString *decoded = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
请参阅docs here。