LSL Wiki : llEscapeURL

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are c-71-202-89-105.hsd1.ca.comcast.net
string llEscapeURL(string url)

Returns the string that is the URL-escaped version of url (replacing spaces with %20, etc).
This function returns the UTF-8 encoded escape codes for selected characters.

Only numbers and ASCII letters are not escaped: [^0-9a-zA-Z]

As of 1.9.0(21) this function only returns a string with 254 characters, this is unacceptable. If all your characters need escaping then this will only allow the user to work with 84 bytes. If those 84 bytes represent 6byte characters (top of the UTF-8 range) then you will only be able to decode 14 characters.- BW

See llUnescapeURL.


Functions
Comments [Hide comments/form]
What happenes when this function encounters a unicode character that can't be represented in a byte (%FF)? does it go for %uXXXX or does it split it into two (or more) UTF-8 bytes? (Apologies, can't test this IW at the moment).
-- ChristopherOmega (2006-04-06 19:47:51)
It returns the UTF-8 character representation. So if fed the string "ф" it would return "%D1%84" and if you inturn feed "%D1%84" to llUnescapeURL you get "ф". On the unicode page you will find character encoding functions that build unicode characters with these two functions.
-- BlindWanderer (2006-04-07 23:40:48)
To work around the 254 character limit, break down the URL...

IE:
(LSL)
        string strURL2Use = URL_POLL_DATA;
        strURL2Use += llEscapeURL("?proj=" + strExpenseProjectData);
        strURL2Use += llEscapeURL("?type=" + strExpenseTypeData);
        strURL2Use += llEscapeURL("?amount=" + strExpenseAmount);
        strURL2Use += llEscapeURL("?note=" + strExpenseTypeNote);
-- NewOddity (2006-08-08 20:42:57)
thats like cheating :P
still a good idea.
it doesn't help you if you are parsing really big strings as paramaters.
-- BlindWanderer (2006-08-10 12:03:20)
i was really annoyed with the 254 character limit, which was way too short for what i wanted, so i wrote my own EscapeURL function, which replaces the most common characters:

// klEscapeURL(string src)
// Returns the string src with URL escaping. (Replaces spaces by %20, etc)
string klEscapeURL(string src)
{
    string tmp;
    integer pos;
    // i read somewhere that jumps were more efficient than for loops. Haven't tested it myself, but using them anyway.
    @loop0;
    pos = llSubStringIndex(src, "%");
    if(pos != -1)
    {
        // There's probably a more effecient way to do this, but i wrote this quickly without thinking too much up front.
        // Can't do llSubStringIndex() constantly because it would keep returning the first, replacing it with %25 and then
        // reporting the % in that one, so making an endless loop. So i take the first part of the string out and store it 
        // temporarily, then continue on the remaining part until there's no more %'s in it.
       tmp += llGetSubString(src, 0, --pos) + "%25";
       src = llDeleteSubString(src, 0, ++pos);
       jump loop0;
    }
    src = tmp + src;
    @loop1;
    pos = llSubStringIndex(src, " ");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%20");
        jump loop1;
    }
    @loop2;
    pos = llSubStringIndex(src, "<");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3C");
        jump loop2;
    }
    @loop3;
    pos = llSubStringIndex(src, ">");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3E");
        jump loop3;
    }
    @loop4;
    pos = llSubStringIndex(src, "#");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%23");
        jump loop4;
    }
    @loop5;
    pos = llSubStringIndex(src, "{");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%7B");
        jump loop5;
    }
    @loop6;
    pos = llSubStringIndex(src, "}");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%7D");
        jump loop6;
    }
    @loop7;
    pos = llSubStringIndex(src, "|");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%7C");
        jump loop7;
    }
    @loop8;
    pos = llSubStringIndex(src, "\\");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%5C");
        jump loop8;
    }
    @loop9;
    pos = llSubStringIndex(src, "^");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%5E");
        jump loop9;
    }
    @loop10;
    pos = llSubStringIndex(src, "~");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%7E");
        jump loop10;
    }
    @loop11;
    pos = llSubStringIndex(src, "[");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%5B");
        jump loop11;
    }
    @loop12;
    pos = llSubStringIndex(src, "]");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%5D");
        jump loop12;
    }
    @loop13;
    pos = llSubStringIndex(src, "`");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%60");
        jump loop13;
    }
    @loop14;
    pos = llSubStringIndex(src, ";");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3B");
        jump loop14;
    }
    @loop15;
    pos = llSubStringIndex(src, "/");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%2F");
        jump loop15;
    }
    @loop16;
    pos = llSubStringIndex(src, "?");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3F");
        jump loop16;
    }
    @loop17;
    pos = llSubStringIndex(src, ":");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3A");
        jump loop17;
    }
    @loop18;
    pos = llSubStringIndex(src, "@");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%40");
        jump loop18;
    }
    @loop19;
    pos = llSubStringIndex(src, "=");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%3D");
        jump loop19;
    }
    @loop20;
    pos = llSubStringIndex(src, "&");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%26");
        jump loop20;
    }
    @loop21;
    pos = llSubStringIndex(src, "$");
    if(pos != -1)
    {
        src = llDeleteSubString(src, pos, pos);
        src = llInsertString(src, pos, "%24");
        jump loop21;
    }
    return src;
}

It's a lot slower than llEscapeURL, but i still got decent speed results with mine even on big strings.
-- KayleeLykin (2007-05-24 01:36:08)
Hello!!!
<a href= http:www.spbgu.ru/blog34606 >female foot domination</a> [url= http:www.spbgu.ru/blog34606 ]female foot domination[/url]<a href= http:www.spbgu.ru/blog34609 >LESBIAN FOOT FETISH</a> [url= http:www.spbgu.ru/blog34609 ]LESBIAN FOOT FETISH[/url]<a href= http:www.spbgu.ru/blog34603 >bdsm domination submission</a> [url= http:www.spbgu.ru/blog34603 ]bdsm domination submission[/url]<a href= http:www.spbgu.ru/blog34610 >friend gate hot mom</a> [url= http:www.spbgu.ru/blog34610 ]friend gate hot mom[/url]
-- proxy.awanti.com (2007-06-11 18:24:02)
Hello!!!
<a href= http:www.spbgu.ru/blog34606 >female foot domination</a> [url= http:www.spbgu.ru/blog34606 ]female foot domination[/url]<a href= http:www.spbgu.ru/blog34609 >LESBIAN FOOT FETISH</a> [url= http:www.spbgu.ru/blog34609 ]LESBIAN FOOT FETISH[/url]<a href= http:www.spbgu.ru/blog34603 >bdsm domination submission</a> [url= http:www.spbgu.ru/blog34603 ]bdsm domination submission[/url]<a href= http:www.spbgu.ru/blog34610 >friend gate hot mom</a> [url= http:www.spbgu.ru/blog34610 ]friend gate hot mom[/url]
-- proxy.awanti.com (2007-06-11 18:26:05)
Attach a comment to this page: