Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > C#/.NET入门教程

asp.net替换和恢复html特殊字符

来源:中文源码网    浏览:241 次    日期:2024-05-17 06:25:47
【下载文档:  asp.net替换和恢复html特殊字符.txt 】


asp.net替换和恢复html特殊字符
/// /// 替换html中的特殊字符 /// /// 需要进行替换的文本。 /// 替换完的文本。 public string HtmlEncode(string theString) { theString=theString.Replace(">", ">"); theString=theString.Replace("<", "<"); theString=theString.Replace(" ", " "); theString=theString.Replace(" ", " "); theString=theString.Replace("\"", """); theString=theString.Replace("\'", "'"); theString=theString.Replace("\n", "
"); return theString; } /// /// 恢复html中的特殊字符 /// /// 需要恢复的文本。 /// 恢复好的文本。 public string HtmlDiscode(string theString) { theString=theString.Replace(">", ">"); theString=theString.Replace("<", "<"); theString=theString.Replace(" "," "); theString=theString.Replace(" "," "); theString=theString.Replace(""","\""); theString=theString.Replace("'","\'"); theString=theString.Replace("
","\n"); return theString; }

相关内容