替换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;
}
/// 替换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;
}
以上就是asp.net替换和恢复html特殊字符的详细内容,更多请关注0133技术站其它相关文章!