ASP
Here you can find some FREE usefull Classic ASP / VBScript code snippets, class modules, etc.
Function Text2HTML(String)String
Converts plain text into safe HTML for proper display.
Example
<% response.write Text2HTML("Smith & Son ©") ' This will return the HTML string "Smith & Son ©" %> Source Code <%
Function Text2HTML(strData) Dim i, c, h, res, htmlChars htmlChars = Split(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,"" & _ ",,,,&,,,,,,,,,,,,,,,,,,,,,,<,,>,,,,,,,,,,,,,,,,," & _ ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," & _ ",,,,,,,,,,,,,,,,,,,,,,, ,¡,¢,£,¤" & _ ",¥,¦,§,¨,©,ª,«,¬," & _ "­,®,¯,°,±,²,³,´," & _ "µ,¶,·,¸,¹,º,»,¼" & _ ",½,¾,¿,À,Á,Â,Ã" & _ ",Ä,Å,Æ,Ç,È,É,Ê," & _ "Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò" & _ ",Ó,Ô,Õ,Ö,×,Ø,Ù," & _ "Ú,Û,Ü,Ý,Þ,ß,à," & _ "á,â,ã,ä,å,æ,ç," & _ "è,é,ê,ë,ì,í,î," & _ "ï,ð,ñ,ò,ó,ô,õ,ö" & _ ",÷,ø,ù,ú,û,ü,ý," & _ "þ,ÿ", ",") ReDim res(Len(strData) - 1) For i = 1 To Len(strData) c = Mid(strData, i, 1) h = htmlChars(Asc(c)) If h = "" Then res(i - 1) = c Else res(i - 1) = h Next Text2HTML = Join(res, "") ReDim res(0): ReDim htmlChars(0): Erase res, htmlChars End Function %> |