asp 获取远程 json 乱码 5C

<%
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.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 = 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%>
<%

txtURL="http://dt.jctytech.com/stock.php?u=test&market=le&type=stock"

sText = getHTTPPage(txtURL)

Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
filename="aaaaaaa.txt"
Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'true为不存在自行建立
openFile.writeline(sText)
Set OpenFile=nothing
set objstream = nothing

%>

文件是乱码的,请问如何解决?

2个回答

getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
你确认是GB2312么,试试看别的编码

response.write sc4Json.Eval("jsonObject.name")&"
"
response.write sc4Json.Eval("jsonObject.content[1].id")

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐