asp 过滤简单html代码程序

作者:袖梨 2022-07-02


 Public Function HTMLEncode(fString)
  If Not IsNull(fString) Then
   fString = replace(fString, ">", ">")
   fString = replace(fString, "<", "<")
   fString = Replace(fString, CHR(32), " ")  
   fString = Replace(fString, CHR(34), """)
   fString = Replace(fString, CHR(39), "'")
   fString = Replace(fString, CHR(9), " ")
   fString = Replace(fString, CHR(13), "")
   fString = Replace(fString, CHR(10) & CHR(10), "

")
   fString = Replace(fString, CHR(10), "
")
   HTMLEncode = fString
  End If
 End Function
 
 '==============================
 '函 数 名:HTMLDncode
 '作    用:字符转回函数
 '参    数:需要转换的文本fString
 '==============================
 Public Function HTMLDncode(fString)
  If Not IsNull(fString) Then
   fString = Replace(fString, ">",">" )
   fString = Replace(fString, "<", "<")
   fString = Replace(fString, " ", CHR(32))
   fString = Replace(fString, " ", CHR(9))
   fString = Replace(fString, """, CHR(34))
   fString = Replace(fString, "'", CHR(39))
   fString = Replace(fString, "", CHR(13))
   fString = Replace(fString, "

",CHR(10) & CHR(10) )
   fString = Replace(fString, "
",CHR(10) )
   HTMLDncode = fString
  End If
 End Function

相关文章

精彩推荐