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\ ...
随机推荐
- javascript模块化---requirejs
requirejs是异步执行 为什么会出现模块化1.不定什么时候,自己就将全局变量改变了2.函数名的冲突3.依赖关系不好管理如果b.js依赖a.js那么b必须放在a的下面解决的办法1.自执行函数来包装 ...
- co-dialog弹出框组件-版本v2.0.0
co-dialog theme 访问git:co-dialog 版本v2.0.0 主题2 coog.app('.theme2').use({ title: 'JUST CHECKING.', mess ...
- java设计模式、框架、架构、平台之间的关系
设计模式<框架<架构<平台,从复用角度讲,设计模式是代码级复用.框架是模块级复用.架构是系统级复用.平台是企业应用级复用. 1.设计模式 为什么要先说设计模式?因为设计模式在 ...
- 【BZOJ2049】[SDOI2008] Cave 洞穴勘测(LCT维护连通性)
点此看题面 大致题意: 有\(n\)个洞穴,\(3\)种操作:连一条边,删一条边,询问两点是否联通. \(LCT\)维护连通性 这道题应该是\(LCT\)动态维护连通性的一道模板题. 考虑将\(x\) ...
- CUDA:Supercomputing for the Masses (用于大量数据的超级计算)-第一节
原文链接 第一节 CUDA 让你可以一边使用熟悉的编程概念,一边开发可在GPU上运行的软件. Rob Farber 是西北太平洋国家实验室(Pacific Northwest National Lab ...
- SpringBoot2.X最佳实践《一》 之 SpringBoot2.x初体验
SpringBoot2.X最佳实践 前言 本系列文章,从零基础接触 SpringBoot2.x新版本,基础入门使用,热部署,到整合各个主流框架Redis4.x,消息队列AciveMQ, Rocket ...
- java算法面试题:有数组a[n],用java代码将数组元素顺序颠倒
package com.swift; import java.util.ArrayList; import java.util.Collections; import java.util.List; ...
- Mysql占用内存过高的优化过程
一.环境说明: 操作系统:CentOS 6.5 x86_64 数据库:Mysql 5.6.22 服务器:阿里云VPS,32G Mem,0 swap 二.问题情况: 1.某日发现公司线上系统的Mysql ...
- redis 设置密码验证
1.找到配置文件:如/etc/redis/redis.conf 2.找到以下内容 # requirepass foobared 3.修改为(redispassword是密码) requirepass ...
- 用dump为什么总会在前面出现/path/debug.php:193
解决方案,在php.ini中的xdebug中加一行代码:xdebug.overload_var_dump=1