欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

[推薦]ASP編程通用函數(shù)收藏大全

 更新時間:2007年08月08日 10:29:45   作者:  

區(qū)分中英文長度,限長截斷標題字符
復制代碼 代碼如下:

<% 
'****************************** 
'函數(shù):InterceptString(txt,length) 
'參數(shù):txt,待判斷截取的標題字符串;length,標題長度 
'作者:阿里西西 
'日期:2007/7/12 
'描述:區(qū)分中英文,限長截斷標題字符 
'示例:<%=InterceptString("歡迎光臨阿里西西WEB開發(fā)網(wǎng)站",8)%> 
'****************************** 
Function InterceptString(txt,length) 
 dim x,y,ii 
 txt=trim(txt) 
 x = len(txt) 
 y = 0 
 if x >= 1 then 
  for ii = 1 to x 
   if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then '如果是漢字 
    y = y + 2 
   else 
    y = y + 1 
   end if 
   if y >= length then 
    txt = left(trim(txt),ii) '字符串限長 
    exit for 
   end if 
  next 
  InterceptString = txt 
 else 
  InterceptString = "" 
 end if 
End Function 
%>

復制代碼 代碼如下:

<%
'******************************
'函數(shù):strLength(str)
'參數(shù):str,待判斷長度的字符串
'作者:阿里西西
'日期:2007/7/12
'描述:求字符串長度。漢字算兩個字符,英文算一個字符
'示例:<%=strLength("歡迎光臨阿里西西")%>
'******************************
function strLength(str)
 ON ERROR RESUME NEXT
 dim WINNT_CHINESE
 WINNT_CHINESE    = (len("中國")=2)
 if WINNT_CHINESE then
        dim l,t,c
        dim i
        l=len(str)
        t=l
        for i=1 to l
         c=asc(mid(str,i,1))
            if c<0 then c=c+65536
            if c>255 then
                t=t+1
            end if
        next
        strLength=t
    else 
        strLength=len(str)
    end if
    if err.number<>0 then err.clear
end function
%>

復制代碼 代碼如下:

采集獲取遠程頁面的內(nèi)容<%
'******************************
'函數(shù):GetURL(url) 
'參數(shù):url,遠程頁面的網(wǎng)址,必須輸入完整格式的網(wǎng)址
'作者:阿里西西
'日期:2007/7/12
'描述:采集獲取遠程頁面的內(nèi)容,很多小偷和采集程序都用到
'示例:<%=GetURL(http://www.alixixi.com/index.html)%>
'******************************
Function GetURL(url) 
Set Retrieval = CreateObject("Microsoft.XMLHTTP") 
With Retrieval 
.Open "GET", url, False
.Send 
GetURL = bytes2bstr(.responsebody)
'對取得信息進行驗證,如果信息長度小于100則說明截取失敗
if len(.responsebody)<100 then
response.write "獲取遠程文件 <a href="&url&" target=_blank>"&url&"</a> 失敗。"
response.end
end if
End With 
Set Retrieval = Nothing 
End Function
' 二進制轉(zhuǎn)字符串,否則會出現(xiàn)亂碼的!
function bytes2bstr(vin) 
strreturn = "" 
for i = 1 to lenb(vin) 
thischarcode = ascb(midb(vin,i,1)) 
if thischarcode < &h80 then 
strreturn = strreturn & chr(thischarcode) 
else 
nextcharcode = ascb(midb(vin,i+1,1)) 
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode)) 
i = i + 1 
end if 
next 
bytes2bstr = strreturn 
end function 
%>


 

相關(guān)文章

最新評論