VBScript函数正在删除外来字符
我在VBScript for Classic ASP中有一个旧函数,它可以在提交表单时去除非法字符,但它也可以去除外来字符,并将它们替换为垃圾字符,如*@L等 函数如下所示:VBScript函数正在删除外来字符,vbscript,Vbscript,我在VBScript for Classic ASP中有一个旧函数,它可以在提交表单时去除非法字符,但它也可以去除外来字符,并将它们替换为垃圾字符,如*@L等 函数如下所示: Private Function stripillegal(fieldcontents) if isnull(fieldcontents) then stripillegal = "" else Dim stripped, stripillegal_c, stripilleg
Private Function stripillegal(fieldcontents)
if isnull(fieldcontents) then
stripillegal = ""
else
Dim stripped, stripillegal_c, stripillegal_i
stripped = ""
if isempty(fieldcontents) then fieldcontents = ""
fieldcontents = CStr( fieldcontents )
fieldcontents = Trim( fieldcontents )
if Len(fieldcontents)>0 then
for stripillegal_i = 1 to Len(fieldcontents)
stripillegal_c = asc(mid(fieldcontents, stripillegal_i, 1))
select case stripillegal_c
case 39
stripped = stripped & "'"
case 37
stripped = stripped & "%"
case 34 ' quote (34)
stripped = stripped & """
case else
stripped = stripped & chr(stripillegal_c)
end select
' response.write stripped & "<br>"
next
end if
stripped = trim(stripped)
while Right(stripped, 1) = chr(13) OR Right(stripped, 1) = chr(10)
stripped = left(stripped, len(stripped)-1)
wend
stripillegal = stripped
end if
End Function
Private函数stripInaligal(fieldcontents)
如果为空(fieldcontents),则
stripInalize=“”
其他的
暗条纹,条纹非法,条纹非法
剥离=“”
如果为空(fieldcontents),则fieldcontents=“”
fieldcontents=CStr(fieldcontents)
fieldcontents=修剪(fieldcontents)
如果Len(fieldcontents)>0,则
对于stripu i=1到Len(fieldcontents)
stripInlockle_c=asc(mid(fieldcontents,stripInlockle_i,1))
选择大小写
案例39
剥离=剥离&“和#39;”
案例37
剥离=剥离&“和#37;”
案例34'引述(34)
剥离=剥离&“和#34;”
其他情况
剥离=剥离&chr(剥离)
结束选择
'response.write&“
”
下一个
如果结束
剥离=修剪(剥离)
右侧(剥离,1)=chr(13)或右侧(剥离,1)=chr(10)
剥离=左侧(剥离,透镜(剥离)-1)
温德
非法的
如果结束
端函数
我想知道如何告诉它允许使用法语或西班牙语中的外来字符。可以很好地清理这些字符串,同时避免使用外来字符
更具体地说,此功能:
Function strClean (strtoclean)
Dim objRegExp, outputStr
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "[(?*"",\\<>&#~%{}+_.@:\/!;]+"
outputStr = objRegExp.Replace(strtoclean, "-")
objRegExp.Pattern = "\-+"
outputStr = objRegExp.Replace(outputStr, "-")
strClean = outputStr
End Function
函数strClean(strtoclean)
Dim objRegExp,outputStr
设置objRegExp=newregexp
objRegExp.IgnoreCase=True
objRegExp.Global=True
objRegExp.Pattern=“[(?*”,\\&&~%{}+.@:\/!;]+”
outputStr=objRegExp.Replace(strtoclean,“-”)
objRegExp.Pattern=“\-+”
outputStr=objRegExp.Replace(outputStr,“-”)
strClean=outputStr
端函数
非常感谢,我试试看!