批量转换内码gb2312为utf-8
<%@ 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(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(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(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
%>
<%
'本程序用来批量转换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(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(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(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
%>
版权声明:
作者:Kiyo
链接:https://www.wkiyo.cn/html/2008-01/i520.html
来源:Kiyo's space
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论