谁能给我一个专门用于替换特殊字符的ASP代码文件!

cdsun 2004-01-14 09:20:07
我想向大家要一个专门替换特殊字符比如'*.`之类的字符
我想作成一个文件再一个网站的所有目录都包含这个文件并且有他相应的功能。
不知道谁有。

谁愿意提供下载!!!

谢谢了。

在这里祝大家新年快乐啊!!!
...全文
198 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
纪俊 2004-01-30
  • 打赏
  • 举报
回复
你可以用下边的函数对其进行html编码然后再用我上边的方法进行显示,一点都不会改变

<% function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function %>
纪俊 2004-01-30
  • 打赏
  • 举报
回复
to

我一直郁闷一件事情。ASP里显示双引号怎么显示?


<%=server.htmlencode("@$#%""""$%^$)%>

上边的方法什么都能显示
杨小杨 2004-01-30
  • 打赏
  • 举报
回复
UBB
cdsun 2004-01-30
  • 打赏
  • 举报
回复
要先用ubb方式替换,然后存入数据库
取出的时候还是要替换回来就好了
fdlm 2004-01-28
  • 打赏
  • 举报
回复
我一直郁闷一件事情。ASP里显示双引号怎么显示?
cdsun 2004-01-28
  • 打赏
  • 举报
回复
up
cdsun 2004-01-19
  • 打赏
  • 举报
回复
自己up一下
wcqgm 2004-01-19
  • 打赏
  • 举报
回复
楼上的方法很不错,如果数据量比较小,可以直接用系统自带的函数就可以了,
如在ASP中用replace(str,"*","")等
在javascript用value.replace("*","")
多加几条就可以了。
紫郢剑侠 2004-01-19
  • 打赏
  • 举报
回复
有没有用JS描述的?

up
flyonet 2004-01-19
  • 打赏
  • 举报
回复
up by flyonet
TrueAndFalse 2004-01-19
  • 打赏
  • 举报
回复
Up
cdsun 2004-01-15
  • 打赏
  • 举报
回复
有没有其他朋友过来分享一下经验?
mikespook 2004-01-14
  • 打赏
  • 举报
回复
用法~~~~

<!-- #Include file="htmlencode.asp" -->
<%=htmlencode2("123<>'")%>

你还需要过滤什么特殊字符呢?

这个函数的扩展性很好~~~比如你要把“1”过滤成“壹”只要这样改这个函数~~
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
'这里加这么一句
case "1"
result=result+"壹"
'就完成了“1”到“壹”的过滤~~~你还需要过滤什么字符自己加吧~~~
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case "'"
result=result+"´"
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
cdsun 2004-01-14
  • 打赏
  • 举报
回复
你这个文件能不能替换所有的特殊字符|?

是否能保存成一个.asp文件然后其他的文件全部include这个文件?

谢谢了
mikespook 2004-01-14
  • 打赏
  • 举报
回复
几乎所有我写的ASP程序里都用的是这个~~~
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case "'"
result=result+"´"
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧