HTML special escape characters

HTML special escape characters
most commonly used character entities
Character Entities
Display Description entity name entity number
and a half square large blank & ensp; & # 8194;
all parties large blank & emsp; & # 8195;
whitespace & nbsp continue to row; & # 160;
<less than & lt; & # 60;
> greater than & gt; & # 62 is;
& & symbol & amp; & # 38 is;
"double quotation marks & quot; & # 34 is;
? Rights & Copy; & # 169;
? is a registered trademark & reg; & # 174;
?? trademark (USA) & # 8482;
× multiplication sign Times &; & # 215;
÷ Divide & divide; & # 247;



/// <summary>
/// Replaces the &lt; with the less then symbol and &gt; with the greater then symbol.
/// </summary>
/// <param name="xml">String to be unescaped</param>
/// <returns>An xml string containing the greter then and less then symbols.</returns>
private string UnEscapeXml(string xml)
{
string result = xml.Replace("&lt;", "<");
result = result.Replace("&gt;", ">");
result = result.Replace("'<'", "&lt;");
result = result.Replace("'quot'", "&quot;");
return result.Replace("'>'", "&gt;");
}

/// <summary>
/// Replaces the less then and greater then symbol with &lt; and &gt;
/// </summary>
/// <param name="xml">String to be escaped</param>
/// <returns>An xml string with &lt; and &gt;</returns>
private string EscapeXml(string xml)
{
string result = xml.Replace("&lt;", "'&lt;'");
result = result.Replace("&quot;", "'quot'");
result = result.Replace("&gt;", "'&gt;'");
result = result.Replace("<", "&lt;");
return result.Replace(">", "&gt;");
}

Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2012/03/12/2391961.html

Guess you like

Origin blog.csdn.net/weixin_34087301/article/details/93494912