没有合适的资源?快使用搜索试试~ 我知道了~
Javascript中escape(),_encodeURI()和encodeURIComponent()之精析与比较.doc
需积分: 9 2 下载量 184 浏览量
2011-07-11
19:12:59
上传
评论
收藏 34KB DOC 举报
温馨提示
试读
3页
Javascript中escape(),_encodeURI()和encodeURIComponent()之精析与比较.doc
资源详情
资源评论
资源推荐
escape(), encodeURI()和 encodeURIComponent()是在 Javascript 中用于编码字符串的三个常用的方法,
而他们之间的异同却困扰了很多的 Javascript 初学者,今天我就在这里对这三个方法详细地分析与比较一
下。
escape() 方法
MSDN JScript Reference 中如是说:
The escape method returns a string value (in Unicode format) that contains the contents of [the
argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are
replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the
character. For example, a space is returned as "%20."
鄙人译:escape 方法以 Unicode 格式返回一个包含传入参数内容的 string 类型的值。 Escape 方法会将
传入参数中所有的空格、标点符号、重音字符以及其它任何非 ASCII 字符替换为%xx 的编码形式,其中
xx 与其所表示的字符的 16 进制数表示形式相同。如空格字符的 16 进制表示形式为 0x20,则此时 xx 应为
20,即 escape(‘ ’) 返回“%20”。
Mozilla Developer Core Javascript Guide 中如是说:
The escape and unescape functions let you encode and decode strings. The escape function returns
the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns
the ASCII string for the specified hexadecimal encoding value.
鄙人译:escape 和 unescape 方法能够帮助你编码和解码字符串。escape 方法对于 ISO Latin 字符集中
的字符组成的参数,返回其 16 进制编码。相对应的,unescape 方法则能将 16 进制编码形式的参数转化
成为其 ASCII 码形式。
encodeURI()方法
MSDN JScript Reference 中如是说:
The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string
is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use
encodeURIComponent to encode these characters.
鄙人译:encodeURI 方法返回一个经过编码的 URI。如果将 encodeURI 方法的编码结果传递给
decodeURI 方法作参数,则能得到原始的未编码的字符串。需要注意到是 encodeURI 方法不编码如下字
符":", "/", ";", and "?"。如果想要编码这些字符,请使用 encodeURIComponent 方法。
Mozilla Developer Core Javascript Guide 中如是说:
Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one,
two, or three escape sequences representing the UTF-8 encoding of the character.
lupo123
- 粉丝: 0
- 资源: 55
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mosquitto-2.018-install-windows-x64
- FTPServer FTP 服务器,绿色免安装,单文件
- 梦畅语音点名软件,上课点名
- 利用ADNI数据集和标签,在tensorflow框架上使用tensorlayer接口,通过架构u-net实现海马体的分割
- Kutools for Word v9.0 office word 插件
- 修复Windows 10 LTSC 2021资源占用率高
- Hash工具,小巧绿色hash校验工具,免费hash工具
- 重启进行BIOS快捷方式,不需要开机按BIOS键
- 鸭子开车记(儿童绘本)
- 威纶通触摸屏编程软件Easy builder pro V6.09.01.556安装包(2024.04).txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0