Home  >  Article  >  Web Front-end  >  What are the differences between escape(), encodeURI(), and encodeURIComponent() in js

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

云罗郡主
云罗郡主forward
2018-10-19 13:59:512445browse

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete