# 一个字 “燚”

unto_lg 2004-08-09 05:47:54

<%
s = "燚"
Response.Write URLDecode(Server.URLEncode (s))

Function URLDecode(strIn)
URLDecode = ""
Dim sl: sl = 1
Dim tl: tl = 1
Dim key: key = "%"
Dim kl: kl = Len(key)
sl = InStr(sl, strIn, key, 1)
Do While sl>0
If (tl=1 And sl<>1) Or tl<sl Then
URLDecode = URLDecode & Mid(strIn, tl, sl-tl)
End If
Dim hh: hh = Mid(strIn, sl+kl, 2)'高位
Dim a: a = Int("&H" & hh)'ascii码
If a<128 Then
sl = sl + 3
Else
Dim hi: hi = Mid(strIn, sl+3+kl, 2)'低位
a = Int("&H" & hh & hi)'非ascii码
sl = sl + 6
End If
URLDecode = URLDecode & Chr(a)
tl = sl
sl = InStr(sl, strIn, key, 1)
Loop
URLDecode = URLDecode & Mid(strIn, tl)
End Function
%>
...全文
173 6 点赞 打赏 收藏 举报

6 条回复

unto_lg 2004-08-10

• 打赏
• 举报

unto_lg 2004-08-10

Function URLDecode(enStr)
dim deStr
dim c,i,v
deStr=""
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval("&h"+Mid(enStr,i+1,2))
if v<128 then
deStr=deStr&chr(v)
i=i+2
else
if isvalidhex(mid(enstr,i,3)) then
if isvalidhex(mid(enstr,i+3,3)) then
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
deStr=deStr&chr(v)
i=i+5
else
v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))
deStr=deStr&chr(v)
i=i+3
end if
else
destr=destr&c
end if
end if
else
if c="+" then
deStr=deStr&" "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
end function

function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
• 打赏
• 举报

mjpclab 2004-08-10
...........................

If a<128 Then
sl = sl + 3
Else
Dim hi
if Mid(strIn, sl+3, 1)="%" Then
hi = Mid(strIn, sl+3+kl, 2)'低位
a = Int("&H" & hh & hi)'非ascii码
else
hi = Hex(Asc(Mid(strIn, sl+3, 1)))'低位
a = Int("&H" & hh & hi)
end if
sl = sl + 6
End If

....................................
• 打赏
• 举报

mjpclab 2004-08-09
"燚" 用 urlencode后得到%A0D，为什么？

• 打赏
• 举报

unto_lg 2004-08-09
yi
• 打赏
• 举报

chang1216 2004-08-09

• 打赏
• 举报

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。

2004-08-09 05:47