国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

C#中HTML字符轉換函數分享

2020-01-18 00:28:47
字體:
來源:轉載
供稿:網友
因此需要以下函數做轉換:
復制代碼 代碼如下:

///<summary>
///替換html中的特殊字符
///</summary>
///<paramname="theString">需要進行替換的文本。</param>
///<returns>替換完的文本。</returns>
public static string HtmlEncode(string theString)
{
theString=theString.Replace(">",">");
theString=theString.Replace("<","<");
theString=theString.Replace(" "," ");
theString=theString.Replace("/"",""");
theString = theString.Replace("/'", "'");
theString=theString.Replace("/n","<br/>");
return theString;
}

///<summary>
///恢復html中的特殊字符
///</summary>
///<paramname="theString">需要恢復的文本。</param>
///<returns>恢復好的文本。</returns>
public static string HtmlDiscode(string theString)
{
theString=theString.Replace(">",">");
theString=theString.Replace("<","<");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","/"");
theString = theString.Replace("'", "/'");
theString=theString.Replace("<br/>","/n");
return theString;
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 申扎县| 伊金霍洛旗| 苏尼特右旗| 金湖县| 罗平县| 旬阳县| 永福县| 永济市| 大埔县| 隆化县| 淮北市| 阳谷县| 焦作市| 靖安县| 安化县| 浙江省| 东至县| 盐城市| 琼结县| 寿光市| 阳高县| 万盛区| 石狮市| 苗栗县| 竹山县| 延安市| 青冈县| 沙坪坝区| 富宁县| 天门市| 怀安县| 舒兰市| 海盐县| 沁源县| 乐都县| 桐梓县| 吉安县| 襄垣县| 哈尔滨市| 芒康县| 大冶市|