Difference between revisions of "LlUnescapeURL"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(21 intermediate revisions by 8 users not shown)
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
|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
|return_text=that is an unescaped/unencoded version of url, replacing %20 with spaces etc.
|return_text=that is an unescaped/unencoded version of {{LSLP|url}}, replacing <code>"%20"</code> with spaces etc.
|spec
|spec
|caveats=
|other_languages={{LSL OL|PHP|[http://php.net/manual/en/function.urldecode.php urldecode]}}{{LSL OL|{{HoverText|ECMAScript|JavaScript, ActionScript, etc}}|[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent decodeURIComponent]}}
|caveats=*The {{Wikipedia|Hexadecimal|hexadecimal}} encoded representation of {{Wikipedia|UTF-8|UTF-8}} {{Wikipedia|Byte|byte}} encoding is the only supported means of access to non ASCII7 characters (Unicode characters).
**Decoding of Unicode as <code>"%u####"</code> is not supported.
*The <code>"+"</code> character is not decoded as a space.
|constants
|constants
|examples
|examples=
<source lang="lsl2">
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"
    }
}
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llEscapeURL]]| Opposite of llUnescapeURL}}
|also_functions={{LSL DefineRow||[[llEscapeURL]]| Opposite of llUnescapeURL}}
Line 16: Line 45:
{{LSL DefineRow||[[UTF-8]]|}}
{{LSL DefineRow||[[UTF-8]]|}}
{{LSL DefineRow||{{LSLGC|Base64}}|}}
{{LSL DefineRow||{{LSLGC|Base64}}|}}
{{LSL_DefineRow||[[Combined_Library#Unicode_Integer_to_UTF8|Combined Library: UnicodeIntegerToUTF8]]|Easily convert unicode character codes to string form.}}
|notes
|notes
|permission
|permission
Line 22: Line 52:
|cat1=Encoding
|cat1=Encoding
|cat2=String
|cat2=String
|cat3
|cat3=Encoding/URL
|cat4
|cat4
}}
}}

Latest revision as of 11:09, 22 January 2015

Summary

Function: string llUnescapeURL( string url );
0.0 Forced Delay
10.0 Energy

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.

Examples

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"
    }
}

See Also

Functions

•  llEscapeURL Opposite of llUnescapeURL

Articles

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

Deep Notes

Signature

function string llUnescapeURL( string url );