一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

网站简繁体转换函数

时间:2022-07-02 23:54:36 编辑:袖梨 来源:一聚教程网

1.gb.asp
<%
'获取服务器生成的html代码
Function GetHTTPPage(url)
dim XmlHttp
set XmlHttp=Server.createobject("Microsoft.XMLHTTP")
XmlHttp.open "GET",url,false
XmlHttp.send()
'getHTTPPage=Http.responseText
if XmlHttp.readystate<>4 then exit function
GetHTTPPage=bytes2BSTR(XmlHttp.responseBody)
set XmlHttp=nothing
if err.number<>0 then err.Clear
End Function
Function Bytes2bStr(vin)
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject("ADODB.Stream")
BytesStream.Type = 2
BytesStream.Open
BytesStream.WriteText vin
BytesStream.Position = 0
BytesStream.Charset = "GB2312"
BytesStream.Position = 2
StringReturn =BytesStream.ReadText
BytesStream.close
Set BytesStream = Nothing
Bytes2bStr = StringReturn
End Function
'转换函数中的页面分隔输出函数
sub splitwords(words)
into=words
out=""
'response.write "共有字数:"&len(into)&"
"
for i=1 to len(into) '循环遍历每个字符
'response.write "现在循环"&i&"/"&len(into)&"次,并开始检测字符"&mid(into,i,1)&"
"
if ascw(mid(into,i,1))<0 or ascw(mid(into,i,1))>255 then '如果是简体中文,进入检测阶段
code=instr(application("gb"),mid(into,i,1)) '获取此字符在简体字库中的位置
if code then'如果在简体字库中出现
out=out&mid(application("other_language"),code,1) '输出在繁体字库中相应的繁体字
'response.write "现在输出繁体第"&i&"个字符:"&mid(application("other_language"),i,1)&"
"
else
out=out&mid(into,i,1) '原样输出
'response.write "现在输出简体第"&i&"个字符"&mid(into,i,1)&"
"

热门栏目