ajax编码问题,中文乱码 asp

来源:百度知道 编辑:UC知道 时间:2024/04/29 03:38:22
我前台用的是gb2312,用xmlhttp的post方法发送数据(内有中文),然后后台是asp
当response.chartset="utf-8",返回中文,但写在asp内的中文是乱码,
当response.chartset="gb2312,返回乱码,写在asp内的中文是正常的
chartset应该改为charset,是刚才写错了

' VBScript 文件

function bytes2BSTR(vIn)
dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn=""
for i=1 to LenB(vIn)
ThisCharCode=AscB(MidB(vIn,i,1))
if ThisCharCode<&H80 Then
strReturn=strReturn & Chr(ThisCharCode)
else
NextCharCode=AscB(MidB(vIn,i+1,1))
strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(NextCharCode))
i=i+1
end if
next
bytes2BSTR=strReturn
end function
参数为xmlhttp.responsebody

晕!response.chartset="gb2312 ,单词写错了

在后台asp文件开头加上
Response.Charset="gb2312"
就行了