Coding Cookbook/HTML Encode

Convert an object (commonly a string) to HTML-safe code.

VBScript solution
Can convert strings and recordsets (converted to tables).

function HTMLEncode (vInput) dim i if IsNull(vInput) then HTMLEncode = vInput exit function end if select case TypeName(vInput) case "Recordset" HTMLEncode = _ " " & vbNewLine case else HTMLEncode = vInput HTMLEncode = Replace(HTMLEncode, chr(0), "") HTMLEncode = Trim(Server.HTMLEncode(HTMLEncode)) HTMLEncode = Replace (HTMLEncode, "'", "&amp;#39;") HTMLEncode = Replace (HTMLEncode, "<", "&amp;lt;") HTMLEncode = Replace (HTMLEncode, ">", "&amp;gt;") HTMLEncode = Replace (HTMLEncode, " ", "&amp;nbsp; ") HTMLEncode = Replace (HTMLEncode, chr(10), " " ) end select end function