首页
VS Code教程
(current)
VS Code插件
(current)
VS Code打造IDE
(current)
VScode更新日志
(current)
关于
C#中HTML字符转换函数分享
316
人浏览 /
0
人评论
因此需要以下函数做转换:
复制代码
代码如下:
///
///替换html中的特殊字符
///
///需要进行替换的文本。
///替换完的文本。
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","");
return theString;
}
///
///恢复html中的特殊字符
///
///需要恢复的文本。
///恢复好的文本。
public static string HtmlDiscode(string theString)
{
theString=theString.Replace(">",">");
theString=theString.Replace("<","<");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","\"");
theString = theString.Replace("'", "\'");
theString=theString.Replace("","\n");
return theString;
}
您可能感兴趣的文章:
C#实现过滤html标签并保留a标签的方法
使用C#获取网页HTML源码的例子
C#中Html.RenderPartial与Html.RenderAction的区别分析
c#使用htmlagilitypack解析html格式字符串
c#远程html数据抓取实例分享
C#下解析HTML的两种方法介绍
C#将html table 导出成excel实例
C#中除去所有在HTML元素中标记
C#实现压缩HTML代码的方法
相关文章
如何有效避免设计作品“空”?
高点击率钻展,设计环节…
无敌配色技巧(一)
留言
全部评论
晴天下起了小雨
2017-10-01 18:00
很喜欢,果断关注了
回复
wjmyly7336064
2017-10-01 18:00
相当实用,赞美了
橘大佬
2017-10-01 18:00
就是有些细节再到位点就好了…
回复
微信公众号
关注微信公众号获取更多VSCode编程信息,定时发布干货文章
最新文章
What's the make money?
MySQL 9.0 的新增功能
Apple 在 iOS 17 中使用 Swift 和 SwiftUI
编写更多“无用”软件
windows 修改环境变量后在 vscode 的终端不生效的两种解决方法
整理列出PHP各个版本5.2至8.0、8.1的特性以及区别
unicode 表情对照表
Stable Diffusion(AI绘画)Lora模型BRA V4发布:AI生成东亚人照片的生态可能因此改变
热门标签
VSCode
python
php
插件
防火墙
nodejs
远程开发
linux
virtualenv
flutter
安卓
苹果
图标主题
mysql
VScode插件
全部评论