Last post Jun 14, 2006 03:42 AM by Liu_andi
Jun 11, 2006 02:38 AM|Liu_andi|LINK
everyone , I use Msxml2.XMLHTTP to access some web page which filled with Chinese character(GB2312),while the result is some stranger code,like this
someone say when access these web page,the return result is coded by utf-8,but how I change them into GB2312, or how can I do ,the result is changed into GB2312 automatically.
Jun 12, 2006 04:49 AM|YongKang|LINK
Please use the following code to have a quick test:
myhttp.open "GET", "http://youriisserver/test1.asp", false
myhttp.SetRequestHeader "Content-Type", "text/xml"
myhttp.SetRequestHeader "charset", "gb2312"
Jun 14, 2006 03:42 AM|Liu_andi|LINK
thank you YongKang.
After I search on the net and get to know that when XMLHTTP sents a reqeust,the response is coded in UTF-8 automatically, so the result we cann't process directly until it is recoded. some methods are presented on the net and I pick up a efficient
way .It like these:
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
ByteToText = objstream.ReadText
set objstream = nothing
The function was coded in vbscript. the first parameter is a string of binary data. the second is the format which you want to recode. so I only pass two parameter to the function then I can get what I want.
str = ByteToText(xmlHttp.responseBody,"GB2312")