当前位置: 移动技术网 > IT编程>开发语言>Asp > asp下实现对HTML代码进行转换的函数

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
<% '****************************** '函数:htmlencode(restring) '参数:restring,待编码转换处理的字符
<%
'******************************
'函数: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
%>

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网