On Tue, 27 Aug 2002, David Neary wrote:> > Actually the following would be in some way sensible:
> > echo -e "`echo "$enc" | sed 's/%\([0-9a-fA-F]\{2,2\}\)/\\\x\1/g'`"
> 
> Why {2,2}? Why not {2}?no idea.the above was something along the lines i was attempting, once i 
realised it was a straight swap. but i couldnt get awk's gensub to 
insert the \x for %'s and ='s.anyway, in the end i found something on the internet and adapted it:function decode_url (str,    hextab,i,c,c1,c2,len,code) {        # hex to dec lookup table
        hextab ["0"] = 0;       hextab ["8"] = 8;
        hextab ["1"] = 1;       hextab ["9"] = 9;
        hextab ["2"] = 2;       hextab ["A"] = 10;
        hextab ["3"] = 3;       hextab ["B"] = 11;
        hextab ["4"] = 4;       hextab ["C"] = 12;
        hextab ["5"] = 5;       hextab ["D"] = 13;
        hextab ["6"] = 6;       hextab ["E"] = 14;
        hextab ["7"] = 7;       hextab ["F"] = 15;        decoded = "";
        i   = 1;
        len = length (str);
        while ( i <= len ) {
                c = substr (str, i, 1);
                # check for usual start of URI hex encoding chars
                if ( c == "%" || c == "=" ) {
                        if ( i+2 <= len ) {
                                # valid hex encoding?
                                c1 = toupper(substr(str, i+1, 1));
                                c2 = toupper(substr(str, i+2, 1));
                                if ( !(hextab [c1] == "" && hextab [c2] == "") ) {
                                        code = 0 + hextab [c1] * 16 + hextab [c2] + 0
                                        c = sprintf ("%c", code)
                                        i = i + 2
                                }
                        }
                # + is space apparently
                } else if ( c == "+" ) {
                        c = " "
                }
                decoded = decoded c;
                ++i;
        }
        return decoded
}> Cheers,
> Dave.> PS the late reply is because the footer on the original mail (If
> you received this mail in error yadda yadda) got caught in my
> spam filter, and ended up in my junkmail directory.he he...might not have been the footer - check my headers. :)regards,
-- 
Paul Jakma	paul@clubi.ie	paul@jakma.org	Key ID: 64A2FF6A
	warning: do not ever send email to spam@dishone.st
Fortune:
One nuclear bomb can ruin your whole day.
-- 
Irish Linux Users' Group: ilug@linux.ie
http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
List maintainer: listmaster@linux.ie