Difference between revisions of "LlUnescapeURL"

From Second Life Wiki
Jump to navigation Jump to search
m (added some wikipedia links, code tags and description of URL structure)
m
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func_id=308|func_sleep=0.0|func_energy=10.0
|func_id=308|func_sleep=0.0|func_energy=10.0
|func=llUnescapeURL|return_type=string|p1_type=string|p1_name=url|p1_desc=A valid and escaped URL.
|func=llUnescapeURL|return_type=string|p1_type=string|p1_name=url|p1_desc=A (preferably valid and escaped URL) string.
|func_footnote=
|func_footnote=
|func_desc
|func_desc
Line 10: Line 10:
**Decoding of Unicode as <code>"%u####"</code> is not supported.
**Decoding of Unicode as <code>"%u####"</code> is not supported.
*The <code>"+"</code> character is not decoded as a space.
*The <code>"+"</code> character is not decoded as a space.
Sample URL: [https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo/bar?arg=gra {{HoverTextStyle|style=color:green;|<nowiki>https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322</nowiki>|2={{String|x-script-url}} = {{String|https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322}}}}{{HoverTextStyle|style=color:blue;|/foo/bar|2={{String|x-path-info}} = {{String|/foo/bar}}}}?{{HoverTextStyle|style=color:red;|1=arg=gra|2={{String|x-query-string}} = {{String|1=arg=gra}}}}]
{{{!}} class="lltable" style="font-size: 85%; text-align: center; width: auto; border=1px;"
! description of URL part
! example
{{!}}-
{{!}} Base URL
{{!}} <font color="green"><nowiki>https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322</nowiki></font>
{{!}}-
{{!}} Trailing path information
{{!}} <font color="blue">/foo/bar</font>
{{!}}-
{{!}} Any query arguments, the text past the first "?" in the URL
{{!}} <font color="red">arg=gra</font>
{{!}}}
|constants
|constants
|examples=
|examples=

Revision as of 11:06, 27 January 2014

Summary

Function: string llUnescapeURL( string url );

Returns a string that is an unescaped/unencoded version of url, replacing "%20" with spaces etc.

• string url A (preferably valid and escaped URL) string.
This function is similar to functions (e.g. urldecode, decodeURIComponent) found in many other languages: 
PHP
urldecode
ECMAScript
decodeURIComponent

Caveats

  • The "Wikipedia logo"hexadecimal encoded representation of "Wikipedia logo"UTF-8 "Wikipedia logo"byte encoding is the only supported means of access to non ASCII7 characters (Unicode characters).
    • Decoding of Unicode as "%u####" is not supported.
  • The "+" character is not decoded as a space.
All Issues ~ Search JIRA for related Bugs

Examples

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

default {

   state_entry()
   {
       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"
   }

}

</lsl>

See Also

Functions

•  llEscapeURL Opposite of llUnescapeURL

Articles

•  UTF-8
•  Base64
•  Combined Library: UnicodeIntegerToUTF8 Easily convert unicode character codes to string form.

Deep Notes

Search JIRA for related Issues

Signature

function string llUnescapeURL( string url );