'*********************************************************
' 目的: Save Text to File
' 输入:
' 输入:
' 返回:
'*********************************************************
Function SaveToFile(strFullName,strContent,strCharset,bolRemoveBOM)
On Error Resume Next
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = adTypeText
.Mode = adModeReadWrite
.Open
.Charset = strCharset
.Position = objStream.Size
.WriteText = strContent
.SaveToFile strFullName,adSaveCreateOverWrite
.Close
End With
Set objStream = Nothing
If bolRemoveBOM Then
If strContent<>"" And ZC_STATIC_TYPE="shtml" Then
Call RemoveBOM(strFullName)
End If
End If
Err.Clear
End Function
'*********************************************************
'*********************************************************
' 目的: Load Text form File
' 输入:
' 输入:
' 返回:
'*********************************************************
Function LoadFromFile(strFullName,strCharset)
On Error Resume Next
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = adTypeText
.Mode = adModeReadWrite
.Open
.Charset = strCharset
.Position = objStream.Size
.LoadFromFile strFullName
LoadFromFile=.ReadText
.Close
End With
Set objStream = Nothing
Err.Clear
End Function
'*********************************************************
'*********************************************************
' 目的: Remove BOM from UTF-8
'*********************************************************
Function RemoveBOM(strFullName)
On Error Resume Next
Dim objStream
Dim strContent
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = adTypeBinary
.Mode = adModeReadWrite
.Open
.Position = objStream.Size
.LoadFromFile strFullName
.Position = 3
strContent=.Read
.Close
End With
Set objStream = NoThing
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = adTypeBinary
.Mode = adModeReadWrite
.Open
.Position = objStream.Size
.Write = strContent
.SaveToFile strFullName,adSaveCreateOverWrite
.Close
End With
Set objStream = Nothing
Err.Clear
End Function