Sample code for 30+ languages & platforms
JavaScript

URL Encoding and Decoding

Demonstrates URL encoding/decoding using the HTTP convenience methods.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var http = new CkHttp();

var s = "Hello World! 100% sure.";

var encoded = http.UrlEncode(s);
console.log("URL encoded: " + encoded);

// Space → %20
// ! → %21
// % → %25

var decoded = http.UrlDecode(encoded);
console.log("URL decoded: " + decoded);

// Output:

// URL encoded: Hello%20World%21%20100%25%20sure.
// URL decoded: Hello World! 100% sure.