风易博客

风萧萧兮易水寒, 壮士一去兮不复还。

« 对台海战后台湾政府治理和定位的思考十万火急提醒你五件事! »

文件格式互转,支持UTF-8,GB2312,BIG5

会说话的博客,点我试试:)
<%
path = Server.MapPath("sss.asp")
Set fso = server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(path)=false then
body = "Hello"
response.End
end If

Set fs = fso.OpenTextFile(path,1)
body = fs.ReadAll
Set fs = Nothing
Set fso = Nothing

Call File_WriteCode("gb2312.asp",body,"","8","gb2312")

Response.WRite "成功"
response.End


'写各编码文件
function File_WriteCode(FileUrl,byval Str,Cre,ReWrite,CharSet)
'文件路径,要写入的数据,没有的话是否新建,已经有的话是否覆盖,编码
if Cre<>false or cre<>true then cre=true
if Cre<>"false" or cre<>"true" then cre=true
if ReWrite="" then ReWrite=2'没有设置是否覆盖,默认为覆盖
if ReWrite<>2 or ReWrite<>8 then ReWrite=2
if ReWrite<>"2" or ReWrite<>"8" then ReWrite=2
'if Charset="" then Charset=File_GetCharset(FileUrl)

if instr(FileUrl,":")<=0 then FileUrl=server.MapPath(FileUrl)
set stm=server.CreateObject("adodb.stream")
stm.Type=2 '以本模式读取
stm.mode=3
stm.charset=CharSet
stm.open
if ReWrite=false or ReWrite=8 then'是否重新开始写
stm.LoadFromFile FileUrl
stm.Position = stm.Size'读取位置称到最后,即追加模式写文件
end if
stm.WriteText str
stm.SaveToFile FileUrl,2
File_WriteCode=true
stm.flush
stm.Close
set stm=nothing
end function
%>

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Code detection by Codefense  theme by BokeZhuti

Copyright © 2005 - 2008 风易博客 1982Y.Net.Cn All Rights Reserved.  由Wind88.Net提供优质主机空间
沪ICP备05006417号