|
|
||||
首页
文学作品 网页设计 平面设计 程序设计 考试认证 基础办公 QQ资源 服务器架设 网站运营 网页资源
|
|
|
| 汉南在线 → 网页设计 → Asp动态程序 | |||||||||||
批量将gb2312码的文本文档转为utf-8内码的。 <%@ CodePage = 65001 %> 记得保存时用utf-8码保存。<% '本程序用来批量转换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 %>
| |||||||||||
| >> 相关文章 | |||||||||||
|
授权使用:汉南在线 http://hnzx.hzwz.net/ 经营许可证:陕ICP备05000109号 Powered by:汉南在线 Copyright (c) 2002-2008 汉南在线. All Rights Reserved . |