用户登录
用户注册

分享至

asp下实现对HTML代码进行转换的函数

  • 作者: 你太耀眼0
  • 来源: 51数据库
  • 2021-07-12
<%
'******************************
'函数:htmlencode(restring)
'参数:restring,待编码转换处理的字符串
'作者:阿里西西
'日期:2007/7/15
'描述:对html代码进行转换
'示例:htmlencode("<p>欢迎访问<br>阿里西西</p>")
'******************************
function htmlencode(restring)
 dim str:str=restring
 if not isnull(str) then
  str = uncheckstr(str)
  str = replace(str, "&", "&")
  str = replace(str, ">", ">")
  str = replace(str, "<", "<")
  str = replace(str, chr(32), " ")
     str = replace(str, chr(9), " ")
  str = replace(str, chr(9), "    ")
  str = replace(str, chr(34), """)
  str = replace(str, chr(39), "'")
  str = replace(str, chr(13), "")
  str = replace(str, chr(10), "<br>")
  htmlencode = str
 end if
end function

'反转换html代码

function htmldecode(restring) 
 dim str:str=restring
 if not isnull(str) then
  str = replace(str, "&", "&")
  str = replace(str, ">", ">")
  str = replace(str, "<", "<")
  str = replace(str, " ", chr(32))
     str = replace(str, " ", chr(9))
  str = replace(str, "    ", chr(9))
  str = replace(str, """, chr(34))
  str = replace(str, "'", chr(39))
  str = replace(str, "", chr(13))
  str = replace(str, "<br>", chr(10))
  htmldecode = str
 end if
end function
%>
软件
前端设计
程序设计
Java相关