HTML特殊转义字符列表

HTML特殊转义字符列表
最常用的字符实体
Character Entities
显示 说明 实体名称 实体编号
半方大的空白    
全方大的空白    
不断行的空白格    
< 小于 &lt; &#60;
> 大于 &gt; &#62;
& &符号 &amp; &#38;
" 双引号 &quot; &#34;
? 版权 &copy; &#169;
? 已注册商标 &reg; &#174;
? 商标(美国) ? &#8482;
× 乘号 &times; &#215;
÷ 除号 &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;");
}

转载于:https://www.cnblogs.com/zhangchenliang/archive/2012/03/12/2391961.html

猜你喜欢

转载自blog.csdn.net/weixin_34087301/article/details/93494912