Javascript String toHtmlString(str)
String.prototype.toHtmlString = function (str){ str = (str)? str: this;//from ww w. ja va 2 s . co m if(typeof str!="string") return ""; var len = str.length; var output = ""; for(var i=0; i<len; i++){ switch(str[i]){ case "\t": output += " " break; case "\n": output += "<br />"; break; default: output += str[i]; } } return output; }