
<%@ CodePage = 65001 %>

<%
'本程序用来批量转换gb2312的文本文档的编码为utf-8
Option Explicit
Dim strFiles,istr,xobjFiles,i

istr=""
Call showFileTree(
"D:\wwwdir\eWebEditor")

xobjFiles=Split(strFiles,
"┣┫")
For i=0
to Ubound(xobjFiles,1)
Dim iext

iext=
right(xobjFiles(i),3)
if iext=
"asp" or iext=
"htm" or iext=
"tml" or iext=
".js" or iext=
"css" then Call Save_HtmlFile(xobjFiles(i))
Next

Sub showFileTree() showFileTree(path)
Dim objSubFolder,fso,objFolder,nowpath,objFiles,objSubFolders,objFile
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder=fso.GetFolder(path)
Set objFiles = objFolder.Files
Set objSubFolders=objFolder.Subfolders
For Each objFile in objFiles
strFiles=strFiles & istr & path & "\"&objFile.name
istr="┣┫"
Next
For Each objSubFolder in objSubFolders
nowpath=path&"\"&objSubFolder.name
Call showFileTree(nowpath)
Next
Set objFiles=nothing
Set objFile=nothing
Set objFolder=nothing
Set objSubFolders=nothing
Set fso=nothing
End Sub

Sub Save_HtmlFile() Save_HtmlFile(sFilePath)
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = 2
.Mode = 3
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText = LoadFile(sFilePath)
.SaveToFile sFilePath,2
.Close
End With
Set objStream = Nothing
End Sub

Function LoadFile() LoadFile(strFullName)
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = 2
.Mode = 3
.Open
.Charset = "gb2312"
.Position = objStream.Size
.LoadFromFile strFullName
LoadFile=.ReadText
.Close
End With
Set objStream = Nothing
End Function

%>
共有 0 条评论