ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Life >

Problem of garbled code when obtaining remote XML documents through XMLHTTP

Thursday on January 1st, 1970Life

When using XMLHTTP to obtain remote XML documents (GB2312), garbled code always appears. Because the remote document is encoded in GB2312 and cannot be modified to UTF-8, it can only be processed at the receiving end. I finally found a way to use Adodb.Stream for binary data processing. I tested it and it was basically available, but Kaspersky always screamed to find the virus.

The following code fragment is from babyt's Blog

Function GetBody(Url)Dim objXMLOn Error Resume NextSet objXML = CreateObject("Microsoft.XMLHTTP")With objXML.Open "Get", Url, False, "", "".SendGetBody = .ResponseBodyEnd WithGetBody=BytesToBstr(GetBody,"GB2312")Set objXML = NothingEnd FunctionFunction BytesToBstr(strBody,CodeBase)dim objStreamset objStream = Server.CreateObject("Adodb.Stream")objStream.Type = 1objStream.Mode =3objStream.OpenobjStream.Write strBodyobjStream.Position = 0objStream.Type = 2objStream.Charset = CodeBaseBytesToBstr = objStream.ReadTextobjStream.Closeset objStream = nothingEnd Function

Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/life/Problem-of-garbled-code-when-obtaining-remote-XML-documents-through-XMLHTTP.htm