我写了一个简体转繁体的ASP组件
lfh 2005-01-25 12:41:19 我根据网上的代码写了一个简体转繁体的ASP组件,转换出来的结果不正确,请大家帮忙看看。
组件代码如下:
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session
Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set MyScriptingContext = PassedScriptingContext
Set MyApplication = MyScriptingContext.Application
Set MyRequest = MyScriptingContext.Request
Set MyResponse = MyScriptingContext.Response
Set MyServer = MyScriptingContext.Server
Set MySession = MyScriptingContext.Session
End Sub
Public Sub OnEndPage()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
Public Function GBBIG5(sStr As String, iConver As Integer) As String
On Error Resume Next
Dim STR
If iConver = 1 Then 'BIG5-->GB
STR = StrConv(sStr, vbFromUnicode, &H804)
GBBIG5 = StrConv(STR, vbUnicode, &H404)
ElseIf iConver = 2 Then 'GB-->BIG5
STR = StrConv(sStr, vbFromUnicode, &H404)
GBBIG5 = StrConv(STR, vbUnicode, &H804)
End If
End Function
ASP文件的调用代码如下:
<%@ CodePage=950 %>
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<BODY>
<TITLE> Testing </TITLE>
<HR>
<%
Response.Charset="big5"
dim strOS
strOS=""
%>
<% Set DelphiASPObj = Server.CreateObject("GBBIG5ASP.GBBIG5")
strOS=DelphiASPObj.GBBIG5("中华人民共和国",2)
Response.write strOS
%>
<HR>
</BODY>
</HTML>
页面返回结果如下:
中?人民共和?