如何在字符串中编码HTML [英] How to encode HTML in string
本文介绍了如何在字符串中编码HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个示例字符串
xxx系统,它不会最小化建议添加到系统的收敛角度。
■线性单位:美国调查尺(sft)
在■后面应该有一个标签空间。
我编码如下
string s =线性单位:美国调查脚(sft);
s =
- + s +
推荐答案
你可以使用 HttpServerUtility.HtmlEncode 方法如下。
You can use HttpServerUtility.HtmlEncode Method is as below.
public class SampleClass
{
public string GetEncodedText()
{
return HttpContext.Current.Server.HtmlEncode("<script>unsafe</script>");
}
}
查看以获取更多信息: HTML编码
我希望这会有所帮助给你。
Check this for more info : HTML encoding
I hope this will help to you.
这篇关于如何在字符串中编码HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文