encodeURI和uncodeURIComponent的介绍
encodeURI、decodeURI
encodeURI、decodeURI 对字符转义;不替换特殊字符有18个、(大小写)字母、数字。
替换目标
将字符替换为 HTML URL编码
替换范围
A-Z a-z 0-9 - _ . ! ~ * ' ( ) / ? : @ & = + $ # 不替换,其他都替换。
encodeURI("ABC abc 123") //ABC%20abc%20123
decodeURI("ABC%20abc%20123") //ABC abc 123
encodeURIComponent、decodeURIComponent:
对特殊字符转码,
替换范围: A-Z a-z 0-9 - _ . ! ~ * ' ( ) 不替换,其他都替换。
var set1 = ";,/?:@&=+$";
var set2 = "-_.!~*'()";
var set3 = "#";
var set4 = "ABC abc 123"; console.log(encodeURIComponent(set1)); //%3B%2C%2F%3F%3A%40%26%3D%2B%24
console.log(encodeURIComponent(set2)); // -_.!~*'()
console.log(encodeURIComponent(set3)); // %23
console.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encoded as %20)
encodeURIComponent和encodeURI的区别
范围区别:encodeURIComponent的替换字符 > encodeURI的替换字符
1.encodeURIComponent会替换: / ? : @ & = + $ #
2.encdoeURI不会替换: / ? : @ & = + $ #
var set1 = ";,/?:@&=+$"; // Reserved Characters
var set2 = "-_.!~*'()"; // Unescaped Characters
var set3 = "#"; // Number Sign
var set4 = "ABC abc 123"; // Alphanumeric Characters + Space console.log(encodeURI(set1)); // ;,/?:@&=+$
console.log(encodeURI(set2)); // -_.!~*'()
console.log(encodeURI(set3)); // #
console.log(encodeURI(set4)); // ABC%20abc%20123 (the space gets encoded as %20) console.log(encodeURIComponent(set1)); // %3B%2C%2F%3F%3A%40%26%3D%2B%24
console.log(encodeURIComponent(set2)); // -_.!~*'()
console.log(encodeURIComponent(set3)); // %23
console.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encoded as %20)
encodeURI和uncodeURIComponent的介绍的更多相关文章
- 结合实例详细介绍encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()使用方法
在介绍encodeURI().encodeURIComponent().decodeURI().decodeURIComponent()方法前我们需要了解Global对象的概念: Global(全 ...
- javascript中encodeURI和decodeURI方法使用介绍
encodeURI和decodeURI是成对来使用的,因为浏览器的地址栏有中文字符的话,可以会出现不可预期的错误, 所以可以encodeURI把非英文字符转化为英文编码,decodeURI可以用来把字 ...
- escape(), encodeURI()和encodeURIComponent()(转)
escape(), encodeURI()和encodeURIComponent()是在Javascript中用于编码字符串的三个常用的方法,而他们之间的异同却困扰了很多的Javascript初学 ...
- js中的三个编码函数:escape,encodeURI,encodeURIComponent
1. eacape(): 该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: * @ - _ + . / .其他所有的字符都会被转义序列替换.其它情况下es ...
- escape()、encodeURI()、encodeURIComponent()区别详解--zt
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- JS转义 escape()、encodeURI()、encodeURIComponent()区别详解
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- escape()、encodeURI()、encodeURIComponent()区别详解
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- javascript encodeURI和encodeURIComponent的比较
总结:encodeURI对除三种字符()之外的字符进行编码 encodeURIComponent对除两种字符之外的字符进行编码,保留字符会被转义 在进行SaaS前端开发的时候,大家经常会用到两个Jav ...
- JS 字符串编码函数(解决URL特殊字符传递问题):escape()、encodeURI()、encodeURIComponent()区别详解
javaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
随机推荐
- 我的Android进阶之旅------>Android利用Sensor(传感器)实现水平仪功能的小例
这里介绍的水平仪,指的是比较传统的气泡水平仪,在一个透明圆盘内充满液体,液体中留有一个气泡,当一端翘起时,该气泡就会浮向翘起的一端. 利用方向传感器返回的第一个参数,实现了一个指南针小应用. 我 ...
- HDUJ 2052 Picture 模拟
Picture Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- yum 安装软件时出现 is this ok [y/d/n]
y下载安装 d只下载不安装 n不安装
- gradlew tasks
D:\AndroidWorkSpace\Qi\LocalM>gradlew tasks > Configure project : AAAA > Configure project ...
- hihocoder 在线测试 补提交卡 (Google)
题目1 : 补提交卡 时间限制:2000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho给自己定了一个宏伟的目标:连续100天每天坚持在hihoCoder上提交一个程序.100天过去 ...
- Contiki Network Stack
一.协议栈 主要有两大网络协议栈,uIP和Rime这两大协议栈(network stack): The uIP TCP/IP stack, which provides us with IPv4 ne ...
- VC++中list::list的使用方法总结
本文主题 这几天在做图像处理方面的研究,其中有一部分是关于图像分割方面的,图像目标在分割出来之后要做进一步的处理,因此有必要将目标图像的信息保存在一个变量里面,一开始想到的是数组,但是马上就发现使用数 ...
- javaScript的类型转换
1.javaScript会自动跟据期望将值进行转换,比如 2.下面表列出了一些javaScript的自动转换,其中粗体字表示了出乎意料的转换情况 3.显示的类型转换 尽管类型可以自动进行一些转换,但是 ...
- aoj 0033 玉
図のように二股に分かれている容器があります.1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし.左の筒 B か右の筒 C に玉を入れます.板 D は支点 E を中心に左右 ...
- MySQL-计算当月重新激活客户_20161013
13号的草稿 12号的明天补充更新,最近太忙了. 客户留存率是衡量客户价值经常用的指标,可以反映客户的活跃程度,在互联网企业,尤其是现在手机端流量已经超过PC端流量,在安卓和IOS设备上在线时长的数据 ...