1

我正在从服务器数据中获取 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 */
}

如何解码这些数据。

4

1 回答 1

5

解码 xml 后,使用以下stringByReplacingPercentEscapesUsingEncoding:方法NSString

NSString *decoded = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

请参阅此处的文档

于 2012-09-06T08:52:39.390 回答