What are the differences between escape(), encodeURI(), and encodeURIComponent() in js

云罗郡主
Release: 2018-10-19 13:59:51
forward
2367 people have browsed it

What this article brings to you is about the differences between escape(), encodeURI(), and encodeURIComponent() in js. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

What are the differences between escape(), encodeURI(), and encodeURIComponent() in js

1.escape() cannot be used directly for URL encoding. Its real function is to return the Unicode encoding value of a character.

2.encodeURI() In addition to common symbols, symbols with special meanings in the URL "; / ? : @ & = $ , #" will not be encoded. After encoding, it outputs the UTF-8 form of the symbol with % prepended to each byte.

3.encodeURIComponent() Like "; / ? : @ & = $, #", these symbols that are not encoded in encodeURI() will all be encoded in encodeURIComponent().

4. Neither encodeURI() nor encodeURIComponent() will encode ASCII letters and numbers, nor will they encode these ASCII punctuation marks: - _ . ! ~ * ’ ( ) .

The above is a complete introduction to the differences between escape(), encodeURI(), and encodeURIComponent() in js. If you want to know more aboutJavaScript video tutorial, please pay attention to the PHP Chinese website.

The above is the detailed content of What are the differences between escape(), encodeURI(), and encodeURIComponent() in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!