URL encoding/decoding

encodeURI:

encodeURIComponent:

  • encodeURI() is a function used to encode URL in Javascript.It focuses on encoding the entire URL, so in addition to common symbols, other symbols that have special meaning in the URL "; / ? : @ & = + $ , #", And do not encode. After encoding, it outputs the utf-8 form of the symbol, and adds% before each byte.
  • The difference between encodeURIComponent() and encodeURI() is that it is used to encode individual parts of the URL instead of encoding the entire URL.Therefore "; / ? : @ & = + $ , #", These symbols that are not encoded in encodeURI() will all be encoded in encodeURIComponent().As for the specific encoding method, the two are the same.