濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > ASP URL反編碼函數(shù)代碼

ASP URL反編碼函數(shù)代碼

熱門標(biāo)簽:地圖標(biāo)注宅基地 外呼系統(tǒng)還用卡么 騰訊地圖標(biāo)注商戶關(guān)閉 武漢營銷電話機(jī)器人軟件 徐州人工智能電銷機(jī)器人好用嗎 西寧公司外呼系統(tǒng)平臺(tái) 長沙防封電銷卡品牌 地圖標(biāo)注服務(wù)哪家好 智能電銷機(jī)器人適用于哪些行業(yè)
例如:
我們?cè)诎俣戎兴阉?腳本之家,則網(wǎng)址后面的參數(shù)就是
http://www.baidu.com/s?cl=3wd=%BD%C5%B1%BE%D6%AE%BC%D2

如果我們想將%BD%C5%B1%BE%D6%AE%BC%D2還原為中文,使用下面的函數(shù)即可。
%
response.write urldecode("http://www.baidu.com/s?cl=3wd=%BD%C5%B1%BE%D6%AE%BC%D2")
'================================================
'函數(shù)名:URLDecode
'作 用:URL解碼
'================================================
Function URLDecode(ByVal urlcode)
Dim start,final,length,char,i,butf8,pass
Dim leftstr,rightstr,finalstr
Dim b0,b1,bx,blength,position,u,utf8
On Error Resume Next

b0 = Array(192,224,240,248,252,254)
urlcode = Replace(urlcode,"+"," ")
pass = 0
utf8 = -1

length = Len(urlcode) : start = InStr(urlcode,"%") : final = InStrRev(urlcode,"%")
If start = 0 Or length 3 Then URLDecode = urlcode : Exit Function
leftstr = Left(urlcode,start - 1) : rightstr = Right(urlcode,length - 2 - final)

For i = start To final
char = Mid(urlcode,i,1)
If char = "%" Then
bx = URLDecode_Hex(Mid(urlcode,i + 1,2))
If bx > 31 And bx 128 Then
i = i + 2
finalstr = finalstr ChrW(bx)
ElseIf bx > 127 Then
i = i + 2
If utf8 0 Then
butf8 = 1 : blength = -1 : b1 = bx
For position = 4 To 0 Step -1
If b1 >= b0(position) And b1 b0(position + 1) Then
blength = position
Exit For
End If
Next
If blength > -1 Then
For position = 0 To blength
b1 = URLDecode_Hex(Mid(urlcode,i + position * 3 + 2,2))
If b1 128 Or b1 > 191 Then butf8 = 0 : Exit For
Next
Else
butf8 = 0
End If
If butf8 = 1 And blength = 0 Then butf8 = -2
If butf8 > -1 And utf8 = -2 Then i = start - 1 : finalstr = "" : pass = 1
utf8 = butf8
End If
If pass = 0 Then
If utf8 = 1 Then
b1 = bx : u = 0 : blength = -1
For position = 4 To 0 Step -1
If b1 >= b0(position) And b1 b0(position + 1) Then
blength = position
b1 = (b1 xOr b0(position)) * 64 ^ (position + 1)
Exit For
End If
Next
If blength > -1 Then
For position = 0 To blength
bx = URLDecode_Hex(Mid(urlcode,i + 2,2)) : i = i + 3
If bx 128 Or bx > 191 Then u = 0 : Exit For
u = u + (bx And 63) * 64 ^ (blength - position)
Next
If u > 0 Then finalstr = finalstr ChrW(b1 + u)
End If
Else
b1 = bx * h100 : u = 0
bx = URLDecode_Hex(Mid(urlcode,i + 2,2))
If bx > 0 Then
u = b1 + bx
i = i + 3
Else
If Left(urlcode,1) = "%" Then
u = b1 + Asc(Mid(urlcode,i + 3,1))
i = i + 2
Else
u = b1 + Asc(Mid(urlcode,i + 1,1))
i = i + 1
End If
End If
finalstr = finalstr Chr(u)
End If
Else
pass = 0
End If
End If
Else
finalstr = finalstr char
End If
Next
URLDecode = leftstr finalstr rightstr
End Function

Function URLDecode_Hex(ByVal h)
On Error Resume Next
h = "h" Trim(h) : URLDecode_Hex = -1
If Len(h) > 4 Then Exit Function
If isNumeric(h) Then URLDecode_Hex = cInt(h)
End Function
%>

標(biāo)簽:運(yùn)城 荊門 通遼 普洱 鷹潭 巴彥淖爾 通化 雅安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP URL反編碼函數(shù)代碼》,本文關(guān)鍵詞  ASP,URL,反,編碼,函數(shù),代碼,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP URL反編碼函數(shù)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP URL反編碼函數(shù)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    通化市| 天门市| 连南| 遂昌县| 平江县| 尚义县| 衡南县| 扎兰屯市| 宜兰县| 大田县| 青龙| 当涂县| 榕江县| 秦皇岛市| 永川市| 巴里| 涞水县| 嘉禾县| 开江县| 揭东县| 宣威市| 久治县| 山阳县| 盖州市| 奉贤区| 磐安县| 上饶市| 大庆市| 都兰县| 屏山县| 泰兴市| 革吉县| 郴州市| 井陉县| 巴东县| 通州市| 云林县| 龙海市| 衡阳县| 泸定县| 阜康市|