Godaddy空间动态include时出现的中文乱码问题

X_Craft 2009-11-14 05:58:52
用于动态Include的函数如下:
'================================================
'函数名:Include
'作 用:动态Include asp代码文件
'返回值:空
'================================================
Function Include(filename)
Dim re,content,fso,f,aspStart,aspEnd
set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing
set re=new RegExp
re.pattern="^\s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
do while aspStart>aspEnd+1
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%\>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
set re=nothing
End Function

可以在vbscript代码的任何地方进行如下调用:
Include("123.htm") '123.htm本身能正常显示

vbscript设置了CodePage="936", 其它都正常,唯有Include的调用显示出来的中文都是乱码
估计问题出在:
FileSystemObject
但不知怎么解决,试过重新以UTF8或Unicode或GB2312另存为123.htm再上传,但问题依旧
...全文
127 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2009-11-14
  • 打赏
  • 举报
回复
应该是编码问题,两个页面的编码要统一.
除了页面中要有
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
还应该加上
<%
Session.CodePage=65001
Response.Charset="utf-8"
%>

以上假设为utf-8,如果是gb2312,则代码作相应调整
springgeng 2009-11-14
  • 打赏
  • 举报
回复
支持一下

28,406

社区成员

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

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