replace替换,中文变乱码

wuchen108 2009-02-25 05:36:25
<%'我想用读取test.asp 中的内容,将其中某些字符串替换成某些内容,存储为一个新文件,但是新文件中被替换的部分的中文都是乱码英文和数字正常,其他部分的中文都没有问题,请教下兄弟姐妹们应该如何解决。谢谢了,代码如下:



mbpath=server.MapPath("test.asp")
savein=server.MapPath("test")
set fs=server.CreateObject("scripting.filesystemobject")
set tfile=fs.opentextfile(mbpath)
mb=tfile.readall
tfile.close
tt="abc中文测试123"
temp=replace(mb,"{$title1}",tt)
temp=replace(temp,"{$content1}",tt)
set tfile=fs.createtextfile(savein&"\testth.asp")
tfile.write temp
tfile.close
%>
...全文
645 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuchen108 2009-02-25
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 yanniu008 的回复:]
在输出之前加上下面的代码,
<%
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "gb2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
[/Quote]

加了没有作用,不过谢谢了
yanniu008 2009-02-25
  • 打赏
  • 举报
回复
在输出之前加上下面的代码,
<%
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "gb2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
wuchen108 2009-02-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lianhui1122 的回复:]
编码的问题 用Utf-8
[/Quote]

哥们,用的就是utf-8 ,另外在别人的机器上就没问题
lianhui1122 2009-02-25
  • 打赏
  • 举报
回复
编码的问题 用Utf-8
whdwhd123 2009-02-25
  • 打赏
  • 举报
回复
没用过这个组件
whdwhd123 2009-02-25
  • 打赏
  • 举报
回复
没用过这个组件

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧