{"id":1309,"date":"2014-08-23T17:17:52","date_gmt":"2014-08-23T09:17:52","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=1309"},"modified":"2014-08-23T17:18:26","modified_gmt":"2014-08-23T09:18:26","slug":"asp-sever-urlencode%e5%af%b9%e5%ba%94%e7%9a%84%e4%b8%80%e4%b8%aa%e8%a7%a3%e7%a0%81%e5%87%bd%e6%95%b0-server-urldecode","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/1309","title":{"rendered":"asp-sever.urlencode\u5bf9\u5e94\u7684\u4e00\u4e2a\u89e3\u7801\u51fd\u6570 server.urldecode"},"content":{"rendered":"

asp\u8fd9\u4e2a\u53d8\u6001\u7684\u5bb6\u4f19\uff0c\u6709sever.urlencode\u7f16\u7801\u7684\uff0c\u5374\u6ca1\u6709\u5bf9\u5e94\u7684\u4e00\u4e2a\u89e3\u7801\u51fd\u6570\u3002\u3002\u3002\u7f51\u4e0a\u641c\u7d22\u4e86\u4e00\u4e2aurldecode\u89e3\u7801\u51fd\u6570\uff0c\u4eb2\u6d4b\u53ef\u7528<\/p>\n

\r\nFunction URLDecode(ByVal urlcode)\r\n\tDim start,final,length,char,i,butf8,pass\r\n\tDim leftstr,rightstr,finalstr\r\n\tDim b0,b1,bx,blength,position,u,utf8\r\n\tOn Error Resume Next\r\n\tb0 = Array(192,224,240,248,252,254)\r\n\turlcode = Replace(urlcode,\"+\",\" \")\r\n\tpass = 0\r\n\tutf8 = -1\r\n\tlength = Len(urlcode) : start = InStr(urlcode,\"%\") : final = InStrRev(urlcode,\"%\")\r\n\tIf start = 0 Or length < 3 Then URLDecode = urlcode : Exit Function\r\n\tleftstr = Left(urlcode,start - 1) : rightstr = Right(urlcode,length - 2 - final)\r\n\tFor i = start To final\r\n\tchar = Mid(urlcode,i,1)\r\n\tIf char = \"%\" Then\r\n\tbx = URLDecode_Hex(Mid(urlcode,i + 1,2))\r\n\tIf bx > 31 And bx < 128 Then\r\n\ti = i + 2\r\n\tfinalstr = finalstr & ChrW(bx)\r\n\tElseIf bx > 127 Then\r\n\ti = i + 2\r\n\tIf utf8 < 0 Then\r\n\tbutf8 = 1 : blength = -1 : b1 = bx\r\n\tFor position = 4 To 0 Step -1\r\n\tIf b1 >= b0(position) And b1 < b0(position + 1) Then\r\n\tblength = position\r\n\tExit For\r\n\tEnd If\r\n\tNext\r\n\tIf blength > -1 Then\r\n\tFor position = 0 To blength\r\n\tb1 = URLDecode_Hex(Mid(urlcode,i + position * 3 + 2,2))\r\n\tIf b1 < 128 Or b1 > 191 Then butf8 = 0 : Exit For\r\n\tNext\r\n\tElse\r\n\tbutf8 = 0\r\n\tEnd If\r\n\tIf butf8 = 1 And blength = 0 Then butf8 = -2\r\n\tIf butf8 > -1 And utf8 = -2 Then i = start - 1 : finalstr = \"\" : pass = 1\r\n\tutf8 = butf8\r\n\tEnd If\r\n\tIf pass = 0 Then\r\n\tIf utf8 = 1 Then\r\n\tb1 = bx : u = 0 : blength = -1\r\n\tFor position = 4 To 0 Step -1\r\n\tIf b1 >= b0(position) And b1 < b0(position + 1) Then\r\n\tblength = position\r\n\tb1 = (b1 xOr b0(position)) * 64 ^ (position + 1)\r\n\tExit For\r\n\tEnd If\r\n\tNext\r\n\tIf blength > -1 Then\r\n\tFor position = 0 To blength\r\n\tbx = URLDecode_Hex(Mid(urlcode,i + 2,2)) : i = i + 3\r\n\tIf bx < 128 Or bx > 191 Then u = 0 : Exit For\r\n\tu = u + (bx And 63) * 64 ^ (blength - position)\r\n\tNext\r\n\tIf u > 0 Then finalstr = finalstr & ChrW(b1 + u)\r\n\tEnd If\r\n\tElse\r\n\tb1 = bx * &h100 : u = 0\r\n\tbx = URLDecode_Hex(Mid(urlcode,i + 2,2))\r\n\tIf bx > 0 Then\r\n\tu = b1 + bx\r\n\ti = i + 3\r\n\tElse\r\n\tIf Left(urlcode,1) = \"%\" Then\r\n\tu = b1 + Asc(Mid(urlcode,i + 3,1))\r\n\ti = i + 2\r\n\tElse\r\n\tu = b1 + Asc(Mid(urlcode,i + 1,1))\r\n\ti = i + 1\r\n\tEnd If\r\n\tEnd If\r\n\tfinalstr = finalstr & Chr(u)\r\n\tEnd If\r\n\tElse\r\n\tpass = 0\r\n\tEnd If\r\n\tEnd If\r\n\tElse\r\n\tfinalstr = finalstr & char\r\n\tEnd If\r\n\tNext\r\n\tURLDecode = leftstr & finalstr & rightstr\r\nEnd Function\r\nFunction URLDecode_Hex(ByVal h)\r\n\tOn Error Resume Next\r\n\th = \"&h\" & Trim(h) : URLDecode_Hex = -1\r\n\tIf Len(h) <> 4 Then Exit Function\r\n\tIf isNumeric(h) Then URLDecode_Hex = cInt(h)\r\nEnd Function\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

asp\u8fd9\u4e2a\u53d8\u6001\u7684\u5bb6\u4f19\uff0c\u6709sever.urlencode\u7f16\u7801\u7684\uff0c\u5374\u6ca1\u6709\u5bf9\u5e94\u7684\u4e00\u4e2a\u89e3\u7801\u51fd\u6570\u3002\u3002\u3002\u7f51\u4e0a\u641c\u7d22\u4e86\u4e00\u4e2aurldecode\u89e3\u7801\u51fd\u6570\uff0c\u4eb2\u6d4b\u53ef\u7528 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,”+”<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[218,1,9],"tags":[211,222,223],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1309"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=1309"}],"version-history":[{"count":2,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1309\/revisions"}],"predecessor-version":[{"id":1311,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1309\/revisions\/1311"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=1309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=1309"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}