function encode(v)
{
if(v == null||v=="")
return "";
var result="";
for(var i = 0; i < v.length; i++)
switch(v.charAt(i))
{
case "<": result+="<";break;
case ">": result+=">"; break;
case "&":result+="&";break;
case "\"": result+=""";break;
case "'": result+="'";break;
default:result+=v.charAt(i);break;
}
return result;
}