Just create an interface by following this code.

@interface MREntitiesConverter : NSObject {
NSMutableString* resultString;
}
@property (nonatomic, retain) NSMutableString* resultString;
- (NSString*)convertEntiesInString:(NSString*)s;
@end

@implementation MREntitiesConverter
@synthesize resultString;
- (id)init
{
if([super init]) {
//resultString = [[NSMutableString alloc] init];
}
return self;
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)s {
[self.resultString appendString:s];
}
- (NSString*)convertEntiesInString:(NSString*)s {
if(s == nil) {
NSLog(@”ERROR : Parameter string is nil”);
}
resultString = [[NSMutableString alloc] init];
NSString* xmlStr = [NSString stringWithFormat:@"%@", s];
NSData *data = [xmlStr dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSXMLParser* xmlParse = [[NSXMLParser alloc] initWithData:data];
[xmlParse setDelegate:self];
[xmlParse parse];
NSString* returnStr = [[NSString alloc] initWithFormat:@”%@”,resultString];
[resultString release];
return returnStr;
}
- (void)dealloc {
//[resultString release];
[super dealloc];
}
@end

When you want to decode HTML characters within a string, just call the app like this.

MREntitiesConverter *converter = [[MREntitiesConverter alloc] init];
someStr = [converter convertEntiesInString:@"abcdefghiijXXXYZ"];
[converter release];

Easy enough? ;)


Tagged with:
 

Facebook comments:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

reverse phone lookupTattoo DesignsSEO