添加收藏
 系统管理
 联系方式
  汉南在线网页设计Asp动态程序

批量转换内码gb2312为utf-8
作  者:汉南居士
关键字:ASP技术应用



批量将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
%>
记得保存时用utf-8码保存。


来源:互联网
阅读:150
日期:2007-8-10

【 双击滚屏 】 【 推荐朋友 】 【 收藏 】 【 打印 】 【 关闭 】 【 字体: 】 
上一篇:DIV背景半透明,DIV中的字不半透明
下一篇:ASP提速技巧五则

  >> 相关文章
 
  ·JS+ASP打造无刷新新闻列表
  ·ASP控制ADSI操作IIS站点
  ·检测远程URL是否存在的三种方法
  ·简易日历程序
  ·用asp实现的代码批量修改程序
  ·用Asp隐藏文件路径,实现防盗链
  ·asp中cookies的用法
  ·asp获取当前url及其参数

5.12汶川大地震遇难同胞默哀 | 汉南在线总站 | 免费电影 | BT电影下载 | 东莞信息网 | 流行购商城

授权使用:汉南在线 http://hnzx.hzwz.net/
经营许可证:陕ICP备05000109号 Powered by:汉南在线
Copyright (c) 2002-2007 汉南在线. All Rights Reserved .