html编码和解码
public static string EncodeStr(string str)
{
str = Regex.Replace(str, @"<html[^>]*?>.*?</html>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<html[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<body[^>]*?>.*?</body>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<body[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<meta[^>]*?>.*?</meta>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<meta[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<frame[^>]*?>.*?</frame>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<frame[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<frameset[^>]*?>.*?</frameset>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<frameset[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<iframe[^>]*?>.*?</iframe>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<iframe[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<layer[^>]*?>.*?</layer>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<layer[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<ilayer[^>]*?>.*?</ilayer>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<ilayer[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<applet[^>]*?>.*?</applet>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<applet[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<script[^>]*?>.*?</script>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<script[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<link[^>]*?>.*?</link>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<link[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<style[^>]*?>.*?</style>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<style[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<form[^>]*?>.*?</form>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<form[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<input[^>]*?>.*?</input>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<input[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<textarea[^>]*?>.*?</textarea>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<textarea[^>]*?/>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<select[^>]*?>.*?</select>", "",
RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<select[^>]*?/>", "",
RegexOptions.IgnoreCase);
return HttpUtility.HtmlEncode(str);
}
public static string DecodeStr(string encodeStr)
{
return HttpUtility.HtmlDecode(encodeStr);
}
html编码和解码的更多相关文章
- java编码原理,java编码和解码问题
java的编码方式原理 java的JVM的缺省编码方式由系统的“本地语言环境”设置确定,和操作系统的类型无关 . 在JAVA源文件-->JAVAC-->Class-->Java--& ...
- IO(六)--- 编码和解码
编码: 把看得懂的字符变成看不懂码值这个过程我们称作为编码. 解码: 把码值查找对应的字符,我们把这个过程称作为解码. 注意: 以后编码与解码一般我们都使用统一的码表.否则非常容易出乱码. 常用码表: ...
- RapidJSON 代码剖析(三):Unicode 的编码与解码
根据 RFC-7159: 8.1 Character Encoding JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32. The defa ...
- BASE64编码和解码(VC源代码) 并 内存加载 CImage 图像
BASE64可以用来将binary的字节序列数据编码成ASCII字符序列构成的文本.完整的BASE64定义可见 RFC1421和 RFC2045.编码后的数据比原始数据略长,为原来的4/3.在电子 ...
- Android 中的编码与解码
前言:今天遇到一个问题,一个用户在登录的时候,出现登录失败.但是其他用户登录都是正常的,经过调试发现登录失败的用户的密码中有两个特殊字符: * .# . 特殊符号在提交表单的时候,出现了编码不一样的 ...
- base64编码、解码的C语言实现
转自:http://www.cnblogs.com/yejianfei/archive/2013/04/06/3002838.html base64是一种基于64个可打印字符来表示二进制数据的表示方法 ...
- android Java BASE64编码和解码二:图片的编码和解码
1.准备工作 (1)在项目中集成 Base64 代码,集成方法见第一篇博文:android Java BASE64编码和解码一:基础 (2)添加 ImgHelper 工具类 package com.a ...
- android Java BASE64编码和解码一:基础
今天在做Android项目的时候遇到一个问题,需求是向服务器上传一张图片,要求把图片转化成图片流放在 json字符串里传输. 类似这样的: {"name":"jike&q ...
- Web开发须知:URL编码与解码
通常如果一样东西需要编码,说明这样东西并不适合传输.原因多种多样,如Size过大,包含隐私数据,对于Url来说,之所以要进行编码,是因为Url中有些字符会引起歧义. 例如,Url参数字符串中使用key ...
- python编码:gbk编码与解码
从RF输入的中文会进行unicode编码:u'\u6587\u4ef6\u5230\u8fbe\u6210\u529f' 从orc数据库查询到的中文会进行gbk编码得到ASCII:'\xce\xc4\ ...
随机推荐
- jQuery_2_常规选择器-进阶选择器
进阶选择器: 1. 群组选择器 $("span,em,#box") 获取多个选择器的DOM对象 <div id="d1">div< ...
- linux 命令——13 less(转)
less 工 具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性. 在 more 的时候,我们并没有办法向前 ...
- 使用Eclipse连接SAP云平台上的HANA数据库实例
SAP云平台(Cloud Platform)上的HANA数据库实例有两种方式访问: 1. 通过SAP云平台的基于网页版的Development Tool:SAP HANA Web-Based Deve ...
- IOS 截屏(保存到相册中)
@interface NJViewController () /** * 点击截屏按钮 */ - (IBAction)captureView:(UIButton *)sender; /** * 白色v ...
- 【BZOJ4698】[SDOI2008] Sandy的卡片(后缀数组+二分)
点此看题面 大致题意: 给你\(N\)个序列,若定义两个相同子串为一个子串内所有数加上一个数后能变成另一个串,求所有序列中的最长相同子串的长度. 简单的转化 首先,我们对题目进行一个简单的转化. 要求 ...
- 【BZOJ4540】 [HNOI2016] 序列(莫队)
点此看题面 大致题意: 求出一个序列的一段区间中所有子序列最小值之和. 莫队 这道题其实是一道莫队题. 但是需要大量的预处理. 预处理 先考虑预处理两个数组\(lst_i\)和\(nxt_i\),分别 ...
- 【BZOJ3668】[NOI2014] 起床困难综合症(位运算思想)
点此看题面 大致题意: 给定一些位运算操作,让你在\(0\sim m\)范围内选一个初始值,使其在经过这些运算后得到的结果最大. 前置技能:关于位运算 作为一道位运算的题,如果你不知道什么是位运算,那 ...
- 【51nod1443】路径和树(堆优化dijkstra乱搞)
点此看题面 大致题意:给你一个无向联通图,要求你求出这张图中从u开始的权值和最小的最短路径树的权值之和. 什么是最短路径树? 从\(u\)开始到任意点的最短路径与在原图中相比不变. 题解 既然要求最短 ...
- Processing入门指南
简介 Processing 是由 MIT 媒体实验室的 Casey Reas 和 Benjamin Fry 发明的一种开源可视化编程语言.Processing为数字媒体与娱乐交互设计而创建,其目的是通 ...
- .NET AJAX实例
引用地址:http://blog.csdn.net/qianjiu/article/details/7524228 5.2 Ajax基础http://book.csdn.net/bookfiles/6 ...