日期:2014-05-17  浏览次数:20857 次

产生乱码
function   SendGet(URL)

Response.Charset( "GB2312 ")

Dim   xmlHttp
Dim   retStr


Set   objXML   =   Server.CreateObject( "MSXML2.ServerXMLHTTP ")
on   error   resume   next
if   err   then
Response.Write( " <p> Error:   "   &   err.description   &   " <p> ")
Response.End
end   if

'   Call   the   remote   machine   the   request
objXML.open   "GET ",   URL,   false
'objXML.setRequestHeader   "Content-Type ",   "text/html;   charset=gb2312 "
objXML.send()

Response.Write   "objXML.readyState= "   &   objXML.readyState   &   " <br> "
i   =   0
While   objXML.readyState   <>   4   And   i   <   5
Response.Write   objXML.readyState   &   " <br> "
i   =   i   +   1
objXML.waitForResponse   100
Wend

Response.Write   "Err.Number= "   &   Err.Number   &   " <br> "
'   return   the   response
If   Err.Number   =   0   then    
retStr   =   objXML.ResponseText   'wait   for   receive   response   from   server
else
retStr   =   "false "    
end   If
SendGet   =   retStr             'return   the   response   to   the   caller

set   objXML   =   nothing
end   function


为什么返回的值总为乱码?

------解决方案--------------------
第一行加上
<%@ LANGUAGE= "VBSCRIPT " CODEPAGE= "65001 "%>

再把文件另存为 UTF-8 格式
------解决方案--------------------
加上
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">