decodeURIComponent decoding function

 

  Imagine a scenario where you send friends a link allows you to open, but the link is below one of them, you will not want to hammer him to death

  1. \u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0062\u0069\u006c\u0069\u0062\u0069\u006c\u0069\u002e\u0063\u006f\u006d (Unicode)

  2. http%3A%2F%2Fbilibili.com (UTF-8)

  3. http\x3A\x2F\x2Fbilibili.com (UTF-16)

 

  If you encounter the above situation, the non-programmer might look ignorant force, find each other in their own play, but actually these 3 link is encrypted in different ways to get in,

  And after that we need to decrypt the link above to get the address accessible

 

    At this time, using JS supplied decodeURIComponent functions are to be decrypted, as follows

  Unicode encryption

  

   UTF-8 encryption

  

   UTF16

  

 

   Note: After I tested, this function does not support Gzip, Base64, md5, Hex encryption, etc.

  decodeURIComponent () method using

 

 

    

  Supplement 1: double-sided nature of things are, the decode function, there are opposing encoding function, the encodeURIComponent () 

     Supplement 2: Careful you may also ask a question, what decoding and encoding functions in the URI is?

     URL everyone is familiar with, officially known as uniform resource identifier, commonly known as, address, website, domain name;

      URI officially called the uniform resource identifier, it can be simply understood as, the URL of a URI subset, the equivalent of parent-child relationship

      See: https://www.cnblogs.com/gaojing/archive/2012/02/04/2413626.html

      

Guess you like

Origin www.cnblogs.com/tu-0718/p/11593918.html