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

<%
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之后解码就不会有乱码了.
posted @ 2008-05-27 15:44  margiex  阅读(704)  评论(0编辑  收藏  举报