js 编码、解码与asp.net 编码、解码
js对URL提供:escape,encodeURI,encodeURIComponent 的编码方法encodeURIComponent:推荐使用,它是将中文、韩文等特殊字符转换成utf-8格式的url编码,以是假定给背景转达参数必要利用encodeURIComponent时必要背景解码对utf-8撑持(form中的编码体例和当前页面编码体例不异)
1、escape:不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z
2、encodeURI:不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z
3、encodeURIComponent:不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z
JS编码:var result=encodeURIComponent(unit);
asp.net解码:Server.UrlDecode(Request["result"]);
js函数:
encodeURI("url")//编码
decodeURI("url")//解码
asp.net的函数:
Server.UrlEncode("url")//编码
Server.UrlDecode("url")//解码
JS对URL中的特殊字符的URL编码,函数是encodeURIComponent,这个函数编码等于asp.net中的Server.UrlEncode体例。
在asp.net中,利用Request.QueryString[""].ToString()可以直接对编码后的字符串进行解码,也可利用Server.UrlDecode体例进行解码。
在asp.net中,可利用Request.Url.OriginalString来得到URL,利用Request.Url.ToString(),得到到的地点则是解码过的。
下面是一些使用例子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://localhost:3281/Js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var url = "http://www.cnblogs.com/linJie1930906722?test=测试js对URL的编码";
var escape_Url = escape(url); //escape_Url=http%3A//www.cnblogs.com/linJie1930906722%3Ftest%3D%u6D4B%u8BD5js%u5BF9URL%u7684%u7F16%u7801
var decodeURI_Url = decodeURI(url); // decodeURI_Url=http://www.cnblogs.com/linJie1930906722?test=测试js对URL的编码
var decodeURIComponent_Url = decodeURIComponent(url); //decodeURIComponent_Url=http://www.cnblogs.com/linJie1930906722?test=测试js对URL的编码
var result = "escape_Url=" + escape_Url + " decodeURI_Url=" + decodeURI_Url + " decodeURIComponent_Url=" + decodeURIComponent_Url;
console.log(result);
alert(result);
</script>
</head>
<body> </body>
</html>
js 编码、解码与asp.net 编码、解码的更多相关文章
- js Jquery字符UrlEncode 编码 C#(asp.net)解码 Server HttpUtility 区别 cookies存中文
一.Js asp.net 交互Url编码解码 C#(asp.net)编码:HttpUtility.UrlEncode(url) Jquery解码:decodeURIComponent(url); Jq ...
- C#编码、解码与ASP.NET编码解码对应函数
JavaScript函数分别为:encodeURIComponent/decodeURIComponent C#对应的函数分别为:Uri.EscapeUriString/Uri.EscapeDataS ...
- js和java中URI的编码和解码
js中对文字进行编码主要有三个函数:escape,encodeURI,encodeURIComponent: 对应解码为:unescape,decodeURI,decodeURIComponent 这 ...
- FFmpeg编解码处理4-音频编码
本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/10584948.html FFmpeg编解码处理系列笔记: [0]. FFmpeg时间戳详 ...
- FFmpeg编解码处理3-视频编码
本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/10584937.html FFmpeg编解码处理系列笔记: [0]. FFmpeg时间戳详 ...
- Delphi编码与签名【URL编码与解码,Base64编码与解码,MD5加密,HMAC-SHA1、HMAC-SHA224、HMAC-SHA256、HMAC-SHA384和HMAC-SHA512签名】
作者QQ:(648437169) 点击下载➨delphi编码与签名 [Delphi编码与签名]URL编码与解码,Base64编码与解码,MD5加密,HMAC-SHA1.HMAC-SHA224.HMAC ...
- base64编码的字符串(含有中文) 前端解码
base64编码的字符串(含有中文) 前端解码 https://xue5602.github.io/2018/12/19/atob%E8%A7%A3%E7%A0%81utf-8%E5%AD%97%E7 ...
- 编码解码--三种常见字符编码简介:ASCII、Unicode和UTF-8
什么是字符编码? 计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字节(byte),所以,一个字节能表示的最大的整数就是255( ...
- JS前台base32加密,C#后台解码
公司的系统应用后,客户那边用appscan工具检测到严重的漏洞 1.使用 SQL 注入的认证旁路 (1/2)--未对用户输入正确执行危险字符清理 2.已解密的登录请求 (2/2)----诸如用户名.密 ...
随机推荐
- textField设置输入文字距左边的距离
1.设置tetxField的内边距 [self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@"paddingTop&q ...
- 用Python写爬虫爬取58同城二手交易数据
爬了14W数据,存入Mongodb,用Charts库展示统计结果,这里展示一个示意 模块1 获取分类url列表 from bs4 import BeautifulSoup import request ...
- 【九度OJ】题目1054:字符串内排序
题目描述: 输入一个字符串,长度小于等于200,然后将输出按字符顺序升序排序后的字符串. 输入: 测试数据有多组,输入字符串. 输出: 对于每组输入,输出处理后的结果. 样例输入: bacd 样例输出 ...
- [UCSD白板题] Maximum Pairwise Product
Problem Description Task.Given a sequence of non-negative integers \(a_0, ..., a_{n-1}\),find the ma ...
- JAVA/Android Map与String的转换方法
在Android开发中 Map与String的转换在,在一些需求中经常用到,使用net.sf.json.JSONObject.fromObject可以方便的将string转为Map.但需要导入jar包 ...
- Titanium系列--对Window和View的一点理解
1. window相当于一块屏幕,view相当于一个div层.window拥有全屏和模态化属性,view则没有这2个属性. 2. 创建一个window作为我们的APP的屏幕,之后我们将添加其他元素来丰 ...
- [Python] Removing a non-empty folder
Removing a non-empty folder You will get an ‘access is denied’ error when you attempt to use os.remo ...
- java.lang.RuntimeException: Method setUp in android.test.ApplicationTestCase not mocked. See http://g.co/androidstudio/not-mocked for details.
解决: build.gradle里加入: android { testOptions { unitTests.returnDefaultValues = true } }
- Hbase随笔
大数据时代的数据量是超大规模的,传统的关系数据库已经很难存储和管理这些数据了,为了存储海量数据,我们有了HDFS,它可以把成千上万台服务器上的硬盘聚集成一块超级大的硬盘,为了让这些数据产生价值,我们有 ...
- mobaxterm ssh command
ssh -qTfnNg -D 7070 demouser@echo.supportedns.com -p 2233