function.asp

来自「纪念伟大领袖的专题网站」· ASP 代码 · 共 144 行

ASP
144
字号
<%

    '****************************************************************************
    '' @功能说明: 获得文件扩展名
    '' @参数说明:  
    '' @返回值:   
    '****************************************************************************

function getFileExtName(fileName)
	dim pos
	pos=instrrev(filename,".")
	if pos>0 then
		getFileExtName=mid(fileName,pos+1)
	else
		getFileExtName=""
	end if
end function

function gotTopic(str,strlen)
	dim l,t,c
	l=len(str)
	t=0
	for i=1 to l
		c=Abs(Asc(Mid(str,i,1)))
		if c>255 then
			t=t+2
		else
			t=t+1
		end if
		if t>=strlen then
			gotTopic=left(str,i)&""
			exit for
		else
			gotTopic=str&""
		end if
	next
end function

    '****************************************************************************
    '' @功能说明: 计算源字符串Str的长度(一个中文字符为2个字节长)
    '' @参数说明:  - str [string]: 源字符串
    '' @返回值:   - [Int] 源字符串的长度
    '****************************************************************************
 Public Function strLen(Str)
  If Trim(Str)="" Or IsNull(str) Then 
   strlen=0
  else
   Dim P_len,x
   P_len=0
   StrLen=0
   P_len=Len(Trim(Str))
   For x=1 To P_len
    If Asc(Mid(Str,x,1))<0 Then
     StrLen=Int(StrLen) + 2
    Else
     StrLen=Int(StrLen) + 1
    End If
   Next
  end if
 End Function

    '****************************************************************************
    '' @功能说明: 截取源字符串Str的前LenNum个字符(一个中文字符为2个字节长)
    '' @参数说明:  - str [string]: 源字符串
    '' @参数说明:  - LenNum [int]: 截取的长度
    '' @返回值:   - [string]: 转换后的字符串
    '****************************************************************************
 Public Function CutStr(Str,LenNum)
  Dim P_num
  Dim I,X
  If StrLen(Str)<=LenNum Then
   Cutstr=Str
  Else
   P_num=0
   X=0
   Do While Not P_num > LenNum-2
    X=X+1
    If Asc(Mid(Str,X,1))<0 Then
     P_num=Int(P_num) + 2
    Else
     P_num=Int(P_num) + 1
    End If
    Cutstr=Left(Trim(Str),X)&"…"
   Loop
  End If
 End Function


    '****************************************************************************
    '' @功能说明: 将字符串中的str中的HTML代码进行过滤
    '' @参数说明:  - str [string]: 源字符串
    '' @返回值:   - [string] 转换后的字符串
    '****************************************************************************

function nohtml(str)
    dim re
    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True
    re.Pattern="(\<.[^\<]*\>)"
    str=re.replace(str," ")
    re.Pattern="(\<\/[^\<]*\>)"
    str=re.replace(str," ")
    nohtml=str
    set re=nothing
end function

'替换一切 HTML 标记
function nohtmlcode(str)
	lsstart=instr(1,str,"<",1)
	while lsstart>0
		lsstart=instr(1,str,"<",0)
		if lsstart>0 then
			lsend=instr(lsstart,str,">",0)+1
			lstemp=mid(str,lsstart,lsend-lsstart)
			str=replace(str,lstemp,"",1,-1,1)	'
		end if
	wend

	str=replace(str,"&nbsp;","",1,-1,1) '空格
	str=replace(str,vbcrlf,"",1,-1,1)	'换行符
	str=replace(str,chr(13),"",1,-1,1)	'回车
	str=replace(str,chr(32),"",1,-1,1)	'空格
	str=replace(str,chr(34),"",1,-1,1)	'双引号
	str=replace(str,chr(39),"",1,-1,1)	'单引号
	str=replace(str,"'","",1,-1,1)	'单引号
	str=replace(str,"=","",1,-1,1)	'双引号
	str=replace(str,"/","",1,-1,1)	'单引号
	str=replace(str,"&copy;","",1,-1,1)	'版权号
	str=replace(str,"&reg;","",1,-1,1)	'
	str=replace(str,"&amp;","",1,-1,1)	'
	str=replace(str,"&","",1,-1,1)	'
	str=replace(str,"#","",1,-1,1)	'
	str=replace(str,"<BR>"," ",1,-1,1)	'
	str=replace(str,"<p>"," ",1,-1,1)	'
	str=replace(str,"</p>","",1,-1,1)	'
	str=replace(str,"<B>","",1,-1,1)	'
	str=replace(str,"</B>","",1,-1,1)	'
	str=replace(str,"\n","",1,-1,1)	'
	str=replace(str,"<","",1,-1,1)	'
	str=replace(str,">","",1,-1,1)	'
	nohtmlcode=str
end function
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?