From Second Life Wiki
Revision as of 01:59, 24 January 2014 by Kireji Haiku (Talk | contribs)

Jump to: navigation, search


Function: string llEscapeURL( string url );

Returns a string that is the escaped/encoded version of url, replacing spaces with "%20" etc. The function will escape any character not in [a-zA-Z0-9] to "%xx" where "xx" is the hexadecimal value of the character in UTF-8 byte form.

• string url A valid and unescaped URL.

To clarify, numbers and ASCII7 alphabetical characters are NOT escaped. If a character requires more then one byte in UTF-8 byte form then it returns multiple "%xx" sequences chained together.

This function is similar to functions (e.g. rawurlencode, encodeURIComponent) found in many other languages: 


The function is not appropriate for escaping a url all at once, because the ":" after the protocol, and all of the "/" characters delimiting the various parts, will be escaped. Instead, build the url in parts; escaping parts of the path and query string arguments as needed.

Sample url: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo/bar?arg=gra

description of url part example
Base url https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322
Trailing path information /foo/bar
Any query arguments, the text past the first "?" in the url arg=gra
All Issues ~ Search JIRA for related Bugs


<lsl> string str = "http://wiki.secondlife.com/wiki/LSL Portal";

default {

       llOwnerSay("Plain string:\n\t" + str);
       // output: "http://wiki.secondlife.com/wiki/LSL Portal"

       llOwnerSay("Escaped string:\n\t" + llEscapeURL(str));
       // output: "http%3A%2F%2Fwiki%2Esecondlife%2Ecom%2Fwiki%2FLSL%20Portal"

       llOwnerSay("Escaped string unescaped again:\n\t" + llUnescapeURL( llEscapeURL(str) ));
       // output: "http://wiki.secondlife.com/wiki/LSL Portal"

       // because escaping and unescaping are exact opposite
       // and unescaping an escaped string returns the original

       //  For readability's sake it would make more sense to do:
       llOwnerSay("For readability's sake:\n\t" + "http://wiki.secondlife.com/wiki/" + llEscapeURL("LSL Portal"));
       // output: "http://wiki.secondlife.com/wiki/LSL%20Portal"



See Also


• llUnescapeURL


• UTF-8
• Base64

Deep Notes


  • Prior to SL versions, this function was limited to returning a maximum of 254 characters. SVC-470

Search JIRA for related Issues


function string llEscapeURL( string url );