-
-
Save asimpson/4de93d0f64bd8953b506 to your computer and use it in GitHub Desktop.
Simple method that takes a NSString with HTML entities in it, and cleans that string of those entities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *) format: (NSString *)string { | |
NSAttributedString *formattedString = [[NSAttributedString alloc] initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil]; | |
return formattedString.string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment