找回密码
 加入
搜索
查看: 1794|回复: 2

[IE类操作] xp下写入文件正常,2003下失败

[复制链接]
发表于 2010-7-13 11:15:55 | 显示全部楼层 |阅读模式
$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下生成的文件中文是乱码,要对获取的数据进行编码?
 楼主| 发表于 2010-7-13 11:30:50 | 显示全部楼层
FileOpen($filename,130) 就可以了
请哪位大神解释一下深层次的原理
发表于 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金钱 +20 收起 理由
afan + 20

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 18:14 , Processed in 0.083432 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表