function toTXT(str){
var RexStr = /\<|\>|\"|\‘|\&/g
str = str.replace(RexStr,
function(MatchStr){
switch(MatchStr){
case "<":
return "& lt;";
break;
case ">":
return "& gt;";
break;
case "\"":
return "& quot;";
break;
case "‘":
return "& #39;";
break;
case "&":
return "& amp;";
break;
default :
break;
}
}
)
return str;
}
特殊字符替换 > < " ' &