DecodeURIComponent

From PlainOldWebserver

Jump to: navigation, search

This appears to be the unique complement to encodeURIComponent(). But the following shows it acts like decodeURI().


 var enc_uri = encodeURI(";,/?:@&=+$  ABC");
 document.writeln(" encoded is "+enc_uri);
 var dec_uri = decodeURIComponent(enc_uri);
 document.writeln(" Component decoded is "+dec_uri);
 var enc_uri = encodeURIComponent(";,/?:@&=+$  ABC");
 document.writeln(" Component encoded is "+enc_uri);
 var dec_uri = decodeURIComponent(enc_uri);
 document.writeln(" Component decoded is "+dec_uri);

Result:

  encoded is ;,/?:@&=+$%20%20ABC
  Component decoded is ;,/?:@&=+$  ABC
  Component encoded is %3B%2C%2F%3F%3A%40%26%3D%2B%24%20%20ABC
  Component decoded is ;,/?:@&=+$  ABC
Personal tools
Navigation