【www.gdgbn.com--中文酷站】

<%
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 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码
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 &h3f)
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)’高位
a = int(“&h” & hh)’ascii码
if abs(a)<128 then
sl = sl + 3
else
hi = mid(strin, sl+3+kl, 2)’低位
a = int(“&h” & hh & hi)’非ascii码
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
%>

下面看一款关于站点下gb2312和utf-8页面传递参数乱码的终极解决方法

ansi

<%@language="vbscript" codepage="936"%>
<%session.codepage=936%>




page(gb2312)-111cn.net


<script type="text/网页特效">
document.write("asp教程?keyword=" + escape("木子屋") + "">木子屋");
</script>


<%
response.write(request.querystring("keyword"))
%>


uft-8

 

<%@language="vbscript" codepage="65001"%>
<%session.codepage=65001%>




page(utf-8)-111cn.net


<script type="text/javascript">
document.write("木子屋");
</script>


<%
response.write(request.querystring("keyword"))
%>

本文来源:http://www.gdgbn.com/kuzhan/28525/