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

弃我而去而又重返的人,我会把他忽略。因为他再也给不了我一颗完整的心。将来的一面,我们必须容忍爱人的所有面。
///<summary>
///替换html中的特殊字符
///</summary>
///<paramname="theString">需要进行替换的文本。</param>
///<returns>替换完的文本。</returns>
publicstringHtmlEncode(stringtheString)
{
theString=theString.Replace(">",">");
theString=theString.Replace("<","<");
theString=theString.Replace("","");
theString=theString.Replace("","");
theString=theString.Replace("\"",""");
theString=theString.Replace("\'","'");
theString=theString.Replace("n","<br/>");
returntheString;
} ///<summary>
///恢复html中的特殊字符
///</summary>
///<paramname="theString">需要恢复的文本。</param>
///<returns>恢复好的文本。</returns>
publicstringHtmlDiscode(stringtheString)
{
theString=theString.Replace(">",">");
theString=theString.Replace("<","<");
theString=theString.Replace("","");
theString=theString.Replace("","");
theString=theString.Replace(""",""");
theString=theString.Replace("'","'");
theString=theString.Replace("<br/>","\n");
returntheString;
}

到此这篇关于asp.net替换和恢复html特殊字符就介绍到这了。喜迎阴晴圆缺,笑傲风霜雨雪更多相关asp.net替换和恢复html特殊字符内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: 特殊字符 asp