Old school Easter eggs.
/ /

XtScript Function: urlencode and urldecode

Encode a string for safe use in url, or decode a urlencoded string.

urlencode is an XtScript function that will process a string and encode all special characters (mainly non-alphanumeric) and return the result. space will be encoded to +. For space encoded as %20, see XtScript rawurlencode function.

After encoded, the string then can be safe to send over the url, example for use in GET or POST method.

The urlencoded string can be decoded then using XtScript urldecode function.

XtScript urlencode and urldecode function basic syntax:

<!--parser:xtscript-->
	# Encode a string
	call urlencode $val=...

	# Decode a urlencoded string
	call urldecode $val=...
<!--/parser:xtscript-->

Learn XtScript urlencode and urldecode function from examples

Encode a string for safe use in url query using XtScript urlencode function.

- Code:
<!--parser:xtscript-->
	var $string = http://example.com/example-url-link
	var $encoded = call urlencode $val=$string

	print Bad: http://example.com/path?url=$string
	print <br/><br/>
	print Good: http://example.com/path?url=$encoded
<!--/parser:xtscript-->
- Result:
Bad: http://example.com/path?url=http://example.com/example-url-link

Good: http://example.com/path?url=http%3A%2F%2Fexample.com%2Fexample-url-link

Decode a urlencoded string using urldecode function.

- Code:
<!--parser:xtscript-->
	var $string = This+is+a_urlencoded+%40%23%24%25+string-%29%28%29%3C%3E
	var $decoded = call urldecode $val=$string

	print String: $string
	print <br/><br/>
	print Decoded: $decoded
<!--/parser:xtscript-->
- Result:
String: This+is+a_urlencoded+%40%23%24%25+string-%29%28%29%3C%3E

Decoded: This is a_urlencoded @#$% string-)()<>