關於用ajax出現亂碼的問題

setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
Ajax默認採用的是UTF-8格式傳輸的!

request. getParameterMap()
需要這樣處理

String str = request.getParameterMap().get("xxx");
str = new String(str.getByte("iso-8859-1"), "UTF-8");

 

VBSCRIPT
Function Bin2Str(a_Str)
          Dim sResult,sTemp,sStr
          Dim iLen,i,iAsc

          sResult = ""
          sStr = a_Str
          iLen = LenB(a_Str)

          If iLen=0 Then Exit Function

          For i=1 To iLen
              sTemp = MidB(sStr,i,1)
              iAsc=AscB(sTemp)

              If iAsc<128 Then
                  sResult = sResult & Chr(iAsc)
              Else
                  i=i+1
                  If i <= iLen Then
                      sResult = sResult & Chr(AscW(MidB(sStr,i,1) & sTemp))
                  ElseIf i=iLen+1 Then
                      sResult = sResult & Chr(AscB(sTemp))
                  End If
              End If
          Next

          Bin2Str = sResult
      End Function

 

http://www.51js.com/
http://www.ajan.cn/
 http://www.javaeye.com/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章