28,406
社区成员
发帖
与我相关
我的任务
分享<%
Function utf2gb(Body)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Charset = "gb2312"
objstream.Type = 2
objstream.Mode =3
objstream.Open
objstream.WriteText body
objstream.Position = 0
objstream.Charset = "utf-8"
objstream.Type = 2
utf2gb = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
key=Request.QueryString("key")
key=utf2gb(key)
%>
Public QueryString
Set QueryString = Server.CreateObject("Scripting.Dictionary")
Call ProcessQueryString("utf-8")
Dim key
For Each key In QueryString.Keys
Server.Echo "QueryString(" & key & ") = " & QueryString(key)
Next
Public Sub ProcessQueryString(ByVal charset)
Dim qs, arr, ptr, tmp
qs = Request.ServerVariables("QUERY_STRING")
'qs = "as_q=%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91%E5%85%B1%E5%92%8C%E5%9B%BD&hl=zh-CN&newwindow=1&num=10&btnG=Google+%E6%90%9C%E7%B4%A2&as_epq=&as_oq=&as_eq=&lr=lang_zh-CN&cr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&as_rights="
arr = Split(qs, "&")
For Each ptr In arr
tmp = Split(ptr, "=", 2)
If UBound(tmp) = 1 Then
QueryString(URLDecode(tmp(0), charset)) = URLDecode(tmp(1), charset)
End If
Next
End Sub
Public Function URLDecode(ByVal data, ByVal charset)
Dim strm
Set strm = Server.CreateObject("ADODB.Stream")
With strm
.type = 2
.charset = "iso-8859-1"
.open
.writeText unescape(data)
.position = 0
.charset = charset
URLDecode = .readText(-1)
.close
End With
Set strm = Nothing
End Function