58 c# html-encode string-conversion
我想转换&
为&,"
到"等等.在没有手动编写所有选项的情况下,c#中是否有一个函数可以做到这一点?
Mat*_*ith 99
System.Web.HttpUtility.HtmlDecode()
Run Code Online (Sandbox Code Playgroud)
编辑:从注意这里说:"到Web应用程序之外的编码或解码值,使用..."
System.Net.WebUtility.HtmlDecode()
Run Code Online (Sandbox Code Playgroud)
Ian*_*emp 23
使用静态方法
HttpUtility.HtmlEncode
Run Code Online (Sandbox Code Playgroud)
改&
到&
和"
到"
.使用
HttpUtility.HtmlDecode
Run Code Online (Sandbox Code Playgroud)
做反过来.
using System.Web;
...
var html = "this is a sample & string";
var decodedhtml = HttpUtility.HtmlDecode(html);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
85007 次 |
最近记录: |