gb2312 utf-8 garbled and URL Chinese decoding

Source: Internet
Author: User
Tags abs chr urlencode xmlns

<%
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&LT;SL Then
UrlDecode = UrlDecode & Mid (Strin, TL, SL-TL)
End If
Dim hh, Hi, HL
Dim a
Select Case UCase (Mid (Strin, SL+KL, 1))
Case "U": ' Unicode UrlEncode
A = Mid (Strin, sl+kl+1, 4)
UrlDecode = UrlDecode & ChrW ("&h" & A)
SL = SL + 6
Case "E": ' Utf-8 UrlEncode
HH = Mid (Strin, SL+KL, 2)
a = Int ("&h" & hh) ' ASCII code
If ABS (a) <128 then
SL = SL + 3
UrlDecode = UrlDecode & Chr (a)
Else
Hi = Mid (Strin, SL+3+KL, 2)
HL = Mid (Strin, SL+6+KL, 2)
A = ("&h" & hh and &h0f) * 2 ^12 or ("&h" & Hi and &h3f) * 2 ^ 6 or ("&h" & HL and &h3 F
If a<0 then a = a + 65536
UrlDecode = UrlDecode & ChrW (a)
SL = SL + 9
End If
Case ELSE: ' ASC UrlEncode
HH = Mid (Strin, SL+KL, 2) ' High
a = Int ("&h" & hh) ' ASCII code
If ABS (a) <128 then
SL = SL + 3
Else
Hi = Mid (Strin, SL+3+KL, 2) ' Low
a = Int ("&h" & hh & Hi) ' Non-ASCII code
SL = SL + 6
End If
UrlDecode = UrlDecode & Chr (a)
End Select
TL = SL
SL = InStr (SL, Strin, key, 1)
Loop
UrlDecode = UrlDecode & Mid (Strin, TL)
End Function
%>

Below look at a site on the gb2312 and Utf-8 page Transfer parameter garbled Ultimate Solution

Ansi

<% @language = "VBScript" codepage= "936"%>
<%session.codepage=936%>
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>page (gb2312) -111cn.net</title>

<body>
<script type= "text/web Effects" >
document.write ("<a href= ' t2.asp tutorial? keyword=" + Escape ("wooden House") + "' > Miracle House </a>");
</script>
<br/>
<%
Response.Write (request.querystring ("keyword"))
%>
</body>


Uft-8

<% @language = "VBScript" codepage= "65001"%>
<%session.codepage=65001%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd ">
<meta http-equiv=" Content-type " Content= "text/html; Charset=utf-8 "/>
<title>page (utf-8) -111cn.net</title>

<body>
<script type= "Text/javascript" >
document.write ("<a href= ' t1.asp?keyword=" + Escape ("wooden House") + "' > Miracle House </a> ");
</script>
<br/>
<%
Response.Write (request.querystring ("keyword"))
%>
< /body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.