URLDecode
Decodes a URL-encoded string.
Method Signature
URLDecode(string=[any], charset=[string])
Arguments
Argument
Type
Required
Description
Default
string
any
true
The URL-encoded string to decode.
charset
string
false
The charset to use when decoding the string. Defaults to UTF-8.
UTF-8
Examples
Simple urlDecode() example
Shows how it takes an input of: %21 and returns: !
urlDecode( "%21" );
Result: !
Basic urlDecode() usage
In this example we demonstrate taking a URL encoded message passed on the request context and displaying it decoded.
if( len( rc.MSG ) ) {
writeOutput( encodeForHTML( urlDecode( rc.MSG ) ) );
}
urlDecode() in obfuscation
In this example we demonstrate url encoding a password before it is encrypted, and then decoding it after it is decrypted.
pwd = urlEncodedFormat( "$18$f^$XlTe41" );
writeOutput( pwd & " : " );
pwd = encrypt( pwd, "7Z8of/gKWpqsx/v6O5yHRKanrXsp93B4xIHV97zf88Q=", "BLOWFISH/CBC/PKCS5Padding", "HEX" );
writeOutput( pwd & " : " );
decpwd = decrypt( pwd, "7Z8of/gKWpqsx/v6O5yHRKanrXsp93B4xIHV97zf88Q=", "BLOWFISH/CBC/PKCS5Padding", "HEX" );
writeOutput( decpwd & " : " );
decpwd = urlDecode( decpwd );
writeOutput( decpwd );
Result: %2418%24f%5E%24XlTe41 : : %2418%24f%5E%24XlTe41 : $18$f^$XlTe41
urlDecode() usage as a member function
In this example we demonstrate taking a URL encoded message passed on the request context and displaying it decoded using the urlDecode() member function.
if( len( rc.MSG ) ) {
writeOutput( encodeForHTML( rc.MSG.urlDecode() ) );
}
Additional Examples
encoded_string = "https%3A%2F%2Fdev%2Eboxlang%2Eorg%2Ft%2Fwelcome%2Dto%2Dboxlang%2Ddev%2F2064";
dump( URLDecode( encoded_string ) );
Related
Last updated
Was this helpful?