我根据网上的代码写了一个简体转繁体的ASP组件,转换出来的结果不正确,请大家帮忙看看。
组件代码如下:
Private MyScriptingContext   As ScriptingContext
Private MyApplication   As Application
Private MyRequest   As Request
Private MyResponse   As Response
Private MyServer   As Server
Private MySession   As SessionPublic 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 SubPublic Sub OnEndPage()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End SubPublic 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 IfEnd FunctionASP文件的调用代码如下:
<%@ 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>页面返回结果如下:
中?人民共和? 

解决方案 »

  1.   

    http://wongtaisin.2myweb.net/pure/index_c.htm
      

  2.   

    上面的问题已经用Delphi写组件来解决了,不过现在又有另外一个问题,请看下面的网页代码,页面里通过组件转换后的文字输出到浏览器是正确显示为繁体的,但是页面里的静态中文无论是简体还是繁体都显示为乱码,该怎么解决?网页代码如下:
    <HTML>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    </head>
    <BODY>
    <TITLE> 这里显示为乱码:簡體中文轉換成繁體中文 </TITLE>
    <center>这里显示为乱码:请看标题</center>
    <%
    Response.Charset="big5"
    dim strOS
    strOS=""
    %>
    <% Set DelphiASPObj = Server.CreateObject("GB2BIG5.GB2BIG5") 
       strOS=DelphiASPObj.GBtoBIG5("这里正确显示:简体中文转换成繁体中文")
    Response.write strOS
    %>
    </BODY>
    </HTML>