yejier 发表于 2010-7-13 11:15:55

xp下写入文件正常,2003下失败

$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")

While 1
$filename="d:\增量统计\"&@MON&"-"&@MDAY&".xml"
If FileExists($filename) Then
    Sleep(3600000)
Else
    $oHTTP.Open("GET","http://***",false)
;$oHTTP.setRequestHeader("Cache-Control", "no-cache")
        $oHTTP.setRequestHeader("Accept-Language", "zh-cn")
        $oHTTP.setRequestHeader("Connection", "Keep-Alive" )
        $oHTTP.setRequestHeader("Referer","http://***")
        $oHTTP.Send()

;MsgBox(0,"",$oHTTP.responseText)
        $text=$oHTTP.responseText

        $file = FileOpen($filename, 258)
        FileWrite($file, $text)
        FileClose($file)
EndIf

WEnd

2003下生成的文件中文是乱码,要对获取的数据进行编码?

yejier 发表于 2010-7-13 11:30:50

FileOpen($filename,130) 就可以了
请哪位大神解释一下深层次的原理

shypro2009 发表于 2010-7-13 13:18:40

回复 2# yejier

FileOpen ( "filename" [, mode ] )
130=2+128
258=2+256
2 = 写模式(清除以前的内容)
128 =使用Unicode UTF8的(与BOM)的阅读和写作模式。读不会覆盖现有的BOM。
256 = 使用Unicode UTF8的(无BOM)的阅读和写作模式。

BOM:Byte order mark字节顺序标记, 用于表示Unicode字符结束。
页: [1]
查看完整版本: xp下写入文件正常,2003下失败