首页 > 移动平台 > 详细

iOS -- 转义html中的标签

时间:2017-02-15 11:52:06      阅读:122      评论:0      收藏:0      [点我收藏+]

#pragma mark -- 转义html中的标签

- (NSString *)HTML:(NSString *)html

{

    NSScanner *theScaner = [NSScanner scannerWithString:html];

    NSDictionary *dict = @{@"&amp;":@"&", @"&lt;":@"<", @"&gt;":@">", @"&nbsp;":@"", @"&quot;":@"\"", @"width":@"wid"};

    while ([theScaner isAtEnd] == NO) {

        for (int i = 0; i <[dict allKeys].count; i ++) {

            [theScaner scanUpToString:[dict allKeys][i] intoString:NULL];

            html = [html stringByReplacingOccurrencesOfString:[dict allKeys][i] withString:[dict allValues][i]];

        }

    }

    return html;

}

iOS -- 转义html中的标签

原文:http://www.cnblogs.com/guosir/p/6400511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!