'转换编码 content 要转换编码的内容, cset 目标编码, dest 目标文件绝对路径 Function TransferCharSet(content, cset, dest) Dim Objstream Set Objstream = Server.CreateObject("adodb.stream") objstream.Mode =3 objstream.Charset = cset objstream.Type = 2 objstream.Open objstream.WriteText content objstream.Position = 0 objstream.SaveToFile dest,2 objstream.Close set objstream = nothing End Function '用对应编码读取指定内容 Function getcontent(path) Dim Objstream Set Objstream = Server.CreateObject("Adodb.Stream") objstream.Charset = GetCharSetName(path) objstream.Type = 2 objstream.Mode =3 'objstream.Charset = code objstream.Open Objstream.LoadFromFile path objstream.Position = 0 getcontent = objstream.ReadText objstream.Close set objstream = nothing End Function '取得指定内容的编码名称 Function GetCharSetName(path) Set objstream=server.createobject("Adodb.Stream") objstream.Type=1 objstream.mode=3 objstream.open objstream.Position=0 objstream.loadfromfile path bintou=objstream.read(2) If AscB(MidB(bintou,1,1))=&HEF And AscB(MidB(bintou,2,1))=&HBB Then GetCharSetName="utf-8" ElseIf AscB(MidB(bintou,1,1))=&HFF And AscB(MidB(bintou,2,1))=&HFE Then GetCharSetName="unicode" Else GetCharSetName="gb2312" End If objstream.close Set objstream=nothing End Function