escape()、encodeURI()、encodeURIComponent() difference
escape() 方法:
采用ISO Latin字符集对指定的字符串进行编码。所有的空格符、标点符号、特殊字符以及其他非ASCII字符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编码的16进制数字)。比如,空格符对应的编码是%。
不会被此方法编码的字符: @ * / +
encodeURI() 方法:
把URI字符串采用UTF-8编码格式转化成escape格式的字符串。
不会被此方法编码的字符:! @ # $& * ( ) = : / ; ? + '
encodeURIComponent() 方法:
把 URI字符串采用UTF-8编码格式转化成escape格式的字符串。与encodeURI()相比,这个方法将对更多的字符进行编码,比如 / 等字符。所以如果字符串里面包含了URI的几个部分的话,不能用这个方法来进行编码,否则 / 字符被编码之后URL将显示错误。
不会被此方法编码的字符:! * ( ) '
因此,对于中文字符串来说,如果不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用 escape。如果你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者 encodeURIComponent。
另外,encodeURI/encodeURIComponent是在javascript1.5之后引进的,escape则在javascript1.0版本就有
escape()、encodeURI()、encodeURIComponent() difference的更多相关文章
- javascript中escape()、unescape()、encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()比较
这些URI方法encodeURI.encodeURIComponent().decodeURI().decodeURIComponent()代替了BOM的escape()和unescape()方法.U ...
- JS escape、encodeURI 、encodeURIComponent 编码与解码[转]
转至:http://jc-dreaming.iteye.com/blog/1702407 本文讨论如何对传递参数用JS编码与解码 1:编码与解码方法的对应关系 escape ------------- ...
- [转]ESCAPE()、ENCODEURI()、ENCODEURICOMPONENT()区别详解
escape().encodeURI().encodeURIComponent()区别详解 JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encode ...
- escape、encodeURI和encodeURIComponent的区别及使用
编码 javascript中的编码函数有三种 escape(string) encodeURI(string) encodeURIComponent(string) 解码 相应的解码函数也有以下三种 ...
- Url解码和编码 escape()、encodeURI()、encodeURIComponent()区别详解
Server.UrlDecode;解码 Server.UrlEncode;编码 url编码是一种浏览器用来打包表单输入的格式.浏览器从表单中获取所有的name和其中的值 ,将它们以name/value ...
- escape()、encodeURI()、encodeURIComponent()区别详解 (转)
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:,decodeURI,decodeURIComp ...
- 【转】escape()、encodeURI()、encodeURIComponent()区别详解
escape().encodeURI().encodeURIComponent()区别详解 原文链接:http://www.cnblogs.com/tylerdonet/p/3483836.html ...
- escape()、encodeURI()、encodeURIComponent() 编码解码
escape().encodeURI().encodeURIComponent()区别详解 JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encode ...
- escape、encodeURI以及encodeURIComponent
在标准中,只有字母和数字[0-9a-zA-Z].一些特殊符号"$-_.+!*'(),"[不包括双引号].以及某些保留字,才可以不经过编码直接用于URL.但是比如我们搜索时,往往会输 ...
随机推荐
- php数据库两个关联大表的大数组分页处理,防止内存溢出
$ret = self::$db->select($tables, $fields, $where, $bind); if (!empty($ret)) { $retIds = array(); ...
- js 程序出发事件
<html> <head><title>Test</title></head> <body> <div id='divTe ...
- linqPad帮助你快速学习LINQ
linqPad http://www.cnblogs.com/li-peng/p/3441729.html http://www.linqpad.net/ Linqer http://www.sqlt ...
- PHP 日期比较
$temptime = mktime(8,2,12,4,4,2014);$dt1 = date("Y-m-d",time());$dt2 = date("Y-m-d&qu ...
- C++ 类成员函数作为参数
#include <iostream> using namespace std; typedef int int32_t; struct IMsgBody{ int body; }; st ...
- LINQ to SQL系列四 使用inner join,outer join
先看一个最简单的inner join,在读取Student表时inner join Class表取的对应的Class信息: static void Main(string[] args) { usin ...
- 长城坑爹宽带,劫持用户DNS赚取购物返利
今天回来登录www.jd.com 打算淘点东西,登录后发现地址栏跳到 http://www.jd.com/?utm_source=click.linktech.cn&utm_medium=tu ...
- margin负值
一列li并排的时候,需要一些间距的时候,又不需要最右边或者最左边有间距. <!DOCTYPE html> <html lang="zh-CN"> <h ...
- Swift-04-Designated&&Convenience
class ClassA { let numA:Int init(num: Int){ numA = num } } class ClassB: ClassA { let numB:Int overr ...
- imx6dl i2c4 support
imx6dl i2c4 support 最近的项目用到了imx6dl的i2c4,其实完全可以用gpio-i2c的方法来实现.既然imx6的datasheet中提到有4个i2c,那么一定可以生成i2c的 ...