decodeURIComponent和decodeURI有什么区别? [英] What is the difference between decodeURIComponent and decodeURI?

查看:396
本文介绍了decodeURIComponent和decodeURI有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript函数有什么区别 decodeURIComponent decodeURI

What is the difference between the JavaScript functions decodeURIComponent and decodeURI?

推荐答案

为了解释这两者之间的区别,让我解释一下encodeURI和encodeURIComponent之间的区别。

To explain the difference between these two let me explain the difference between encodeURI and encodeURIComponent.

主要区别在于:


  • encodeURI适用于完整的URI。

  • encodeURIComponent旨在要在..井上使用.. URI组件是
    位于分隔符之间的任何部分(; /?:@& = + $,#)。

因此,在encodeURIComponent中,这些分隔符也被编码,因为它们被视为文本而不是特殊字符。

So, in encodeURIComponent these separators are encoded also because they are regarded as text and not special characters.

现在回到解码函数之间的差异,每个函数解码由其对应的编码对应生成的字符串,负责处理特殊字符的语义及其处理。

Now back to the difference between the decode functions, each function decodes strings generated by its corresponding encode counterpart taking care of the semantics of the special characters and their handling.

这篇关于decodeURIComponent和decodeURI有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆