发出去的信息是乱码,怎么解决
<%
Set https = Server.CreateObject("MSXML2.XMLHTTP")
With https
.Open "Post", "http://www.***.com/api.asp", False
.setRequestHeader "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
c = ""&request("content")&""
c=Server.UrlEncode(c)
.Send "username="&rs("smsname")&"&password="&rs("smspwd")&"&mark=send&mobile="&request("mobile")&"&content="&c&"&fstd=1&sendTime="""
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"GB2312") '返回值
Set https = Nothing
Function BytesToBstr(body,Cset) '转换GB2312
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
<%
if GetBody=0 then
response.write"<SCRIPT language=JavaScript>alert('发送成功!');"
response.write"location.href=""?act=admin"";</SCRIPT>"
else
response.write"<SCRIPT language=JavaScript>alert('发送失败!');"
response.write"location.href=""?act=admin"";</SCRIPT>"
end if
%>
http://www.***.com/api.asp是utf-8的,但是本站是gb2312的,发出去的信息是乱码,请问怎么解决!
[解决办法]
把本站页面编码设置为 与远程页面的编码 一致。