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\ ...
随机推荐
- COGS 11. 运输问题1
★★☆ 输入文件:maxflowa.in 输出文件:maxflowa.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] 一个工厂每天生产若干商品,需运输到 ...
- HDU1075 字典树 + 字符串映射
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 ,字典树的字符串映射. 题意是给你每个火星文单词对应的英语,然后让你把一篇火星文文章给翻译成英语 ...
- UOJ#130 【NOI2015】荷马史诗 K叉哈夫曼树
[NOI2015]荷马史诗 链接:http://uoj.ac/problem/130 因为不能有前缀关系,所以单词均为叶子节点,就是K叉哈夫曼树.第一问直接求解,第二问即第二关键字为树的高度. #in ...
- css img 等比例自动缩放
按父容器宽度自动缩放,并且保持图片原本的长宽比 img{ width: auto; height: auto; max-width: 100%; max-height: 100%; }
- javascrit中“字符串为什么可以调用成员”
<script> var title = "this is title"; console.log(title.substr(0,5)); //字符串为什么可以调用 ...
- java编程基础——从上往下打印二叉树
题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 题目代码 /** * 从上往下打印出二叉树的每个节点,同层节点从左至右打印. * Created by YuKai Fan on 20 ...
- Activiti学习记录(四)
1 连线 注意:如果将流程图放置在和java类相同的路径,需要配置: 1.1 部署流程定义+启动流程实例 ProcessEngine processEngine = ProcessEngines.ge ...
- Oracle Hint 之 Append
1 描述 所谓直接路径操作,就是绕过buffer cache,直接将数据插入到表所在的数据文件中: 假如有表A,要将A中的数据插入到表B,在普通的间接插入下,先将A中的数据块传进buffer cach ...
- 利用Filter解决跨域请求的问题
1.为什么出现跨域. 很简单的一句解释,A系统中使用ajax调用B系统中的接口,此时就是一个典型的跨域问题,此时浏览器会出现以下错误信息,此处使用的是chrome浏览器. 错误信息如下: jquery ...
- thinkphp 3.2.3 - Route.class.php 解析(路由匹配)
class Route { public static function check(){ $depr = C('URL_PATHINFO_DEPR'); // '/' $regx = preg_re ...