Is there a built-in way in the iOS sdk to take an NSString containing HTML sequences
& amp;, & nbsp;, & lt; (spaces added to avoid markdown开发者_如何学编程 interpretation)
etc., and translate those to '&', ' ', '<' ? My string contains international UTF8 characters so I can't convert to ascii.
As Michael Waterfall has commented on other, similar questions, there is no built-in function available, but have a look at his solution which is a new category for NSString.
It defines the following new methods, especially stringByDecodingHTMLEntities:
- (NSString *)stringByConvertingHTMLToPlainText;
- (NSString *)stringByDecodingHTMLEntities;
- (NSString *)stringByEncodingHTMLEntities;
- (NSString *)stringWithNewLinesAsBRs;
- (NSString *)stringByRemovingNewLinesAndWhitespace;
加载中,请稍侯......
精彩评论