首页 > 编程 > ASP > 正文

字符串转换函数

2024-05-04 11:06:01
字体:
来源:转载
供稿:网友

以下是代码片段:
<%
’ ============================================
’ 把字符串进行HTML解码,替换server.htmlencode
’ 去除Html格式,用于显示输出
’ ============================================
Function outHTML(str)
Dim sTemp
sTemp = str
outHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&amp;")
sTemp = Replace(sTemp, "<", "&lt;")
sTemp = Replace(sTemp, ">", "&gt;")
sTemp = Replace(sTemp, Chr(34), "&quot;")
sTemp = Replace(sTemp, Chr(10), "<br>")
outHTML = sTemp
End Function
’ ============================================
’ 去除Html格式,用于从数据库中取出值填入输入框时
’ 注意:value="?"这边一定要用双引号
’ ============================================
Function inHTML(str)
Dim sTemp
sTemp = str
inHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&amp;")
sTemp = Replace(sTemp, "<", "&lt;")
sTemp = Replace(sTemp, ">", "&gt;")
sTemp = Replace(sTemp, Chr(34), "&quot;")
inHTML = sTemp
End Function
%>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表