What is the difference between decodeURIComponent

2013/12/24 10:09
阅读数 116
Q: What is the difference between the JavaScript functions decodeURIComponent and decodeURI?
To explain the difference between these two let me explain the difference between encodeURI and encodeURIComponent.


The main difference is that:
  • encodeURI is intended for use on the full URI.
  • encodeURIComponent is intended to be used on .. well .. URI components that is any part that lies between separators (; / ? : @ & = + $ , #).
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.

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部