This first function will create a urlencoded version of the string it is given. Unlike the regular escape() function, this doesn't just escape special characters, but alphanumeric ones as well. The unescape() part of this is optional, but useful for eval() statements.
function escape(str){
tmp = "unescape('";
for(var i=0;i<str.length;i++) tmp += "%" + str.charCodeAt(i).toString(16);
return tmp + "')";
}
The second function is for creating a list of char numbers to replace a string. This is useful if you are unable to use quotation marks (for whatever reason). The String.fromCharCode is used for returning the characters back to a string, but it is optional.
function toChars(str){
var ret = "String.fromCharCode(";
for(var i=0;i<str.length;i++) ret += str.charCodeAt(i) + ",";
return ret.slice(0,ret.length-1) + ")";
}
Hopefully you can find a use for one or both of these functions.



