您的位置:首页 > 编程语言 > ASP

asp中接收到querystring是utf-8编码的处理方式

2008-05-27 15:44 302 查看
<%

response.charset = "utf-8"

response.write URLDecode(request.querystring("msg") +"<BR>")

Function URLDecode(sConvert)

Dim aSplit

Dim sOutput

Dim I

If IsNull(sConvert) Then

URLDecode = ""

Exit Function

End If

' convert all pluses to spaces

sOutput = REPLACE(sConvert, "+", " ")

' next convert %hexdigits to the character

aSplit = Split(sOutput, "%")

If IsArray(aSplit) Then

sOutput = aSplit(0)

For I = 0 to UBound(aSplit) - 1

sOutput = sOutput & _

Chr("&H" & Left(aSplit(i + 1), 2)) &_

Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)

Next

End If

URLDecode = sOutput

End Function

%>

将ASP的页面charset设置为utf-8之后解码就不会有乱码了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: