#pragma mark -- 转义html中的标签
- (NSString *)HTML:(NSString *)html
{
NSScanner *theScaner = [NSScanner scannerWithString:html];
NSDictionary *dict = @{@"&":@"&", @"<":@"<", @">":@">", @" ":@"", @""":@"\"", @"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;
}
时间: 2024-10-22 02:43:56