Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback on: Creating 'Encoded' Name & Value Pairs, January 20, 2002 at 04:08:52:

You are here: irt.org | About | Feedback | 3505 [ previous next ]

Feedback on:
Creating 'Encoded' Name & Value Pairs

Sent by
John McGuire on January 20, 2002 at 04:08:52:

Worth:
Very worth reading

Comments:
I thought you might like this bit of coding for the users that needed to decode spaces as + and can't use the hex equivelent.

function dcode(string) {
string = unescape(string);
string = replace(string,"+"," ");
return string;
}


function replace(string,text,by) {
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;

var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;

var newstr = string.substring(0,i) + by;

if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);

return newstr;
}

I hope this is useful. The replace can be used for other things as well. Please let me know if this coes in hand.

John McGuire
BlackLight Systems Design


Other feedback on 'Creating 'Encoded' Name & Value Pairs' - show all

©2018 Martin Webb