在JSP里设置返回的内容为 TEXT/XML, 字符集为 GB2312

解决方案 »

  1.   

    哦,错了,不是jscript,应该是javascript.
      

  2.   

    两种方法
    一、自己写编码转换函数
    二、用 ADODB.STREAM 转换
      

  3.   

    在javascript中可以用adodb.stream吗,我查一下。谢谢提醒。
      

  4.   

    谁有完整的adodb.stream代码js的
    帮忙帖一下吧
    我这只有vbs的
      

  5.   

    <script language=VBScript>
    function getHTTPPage(url)
       dim Http
       set http=createobject("Microsoft.XMLHTTP") 
       Http.open "GET",url,false
       Http.send()
       if Http.readystate<>4 then
       exit function
       end if
       getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
       set http=nothing
       if err.number<>0 then err.Clear
    end function
    Function BytesToBstr(body,Cset)
    dim objstream
    set objstream = 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
    Dim Url,Html
       Url="http://www.seasky.biz/"
       Html = getHTTPPage(Url)
       document.write(Html)
    </script>
      

  6.   

    我也遇到这个问题,解决方法如下:
    将返回的XML数据的第一行写成:<?xml version="1.0" encoding="gb2312" ?>你试试看,如果可以就加分!
      

  7.   

    1.可以用Drowning(暑假過完了~~) 给的方法进行转换~
    2.可以用楼上的方法,返回XML数据,加入<?xml version='1.0' encoding='gb2312'?>