<%
public function cn2en(l1)
    dim I1,I2,l2,l3,l4,i,rs,temp,strsql
    set I2=server.createobject("adodb.connection")
    I2.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath("../db/pinyin.mdb")
    if err.number<>0 then response.Write("error")
    l4=true
    for i=1 to len(l1)
        l3=l4
        l2=mid(l1,i,1)
        if len(trim(l2))=1 then
            StrSql="select top 1 pinyin,hanzi from Hzpy where hanzi ='"&l2&"' and PutOut=true"
            set rs=server.CreateObject("adodb.recordset")
            rs.open Strsql,I2,1,2
                if not rs.eof and not rs.bof then
                    l2=rs(0)
                      If len(l2)>0 then
                           l2=Ucase(Left(l2,1)) & right(l2,len(l2)-1)
                      End If  
                    l4=true
                else
                    rs.addnew
                       rs("hanzi")=l2
                    rs.update
                    l2="_"            
                    l4=false
                end if
                rs.close
            set rs=nothing
        else
            l2=""
        end if
        if l3=l4 then
            I1=I1&l2
        else
            I1=I1&""&l2
        end if
    next
    I2.close
    set I2=nothing
    cn2en=trim(I1)
end function

cns=request.QueryString("cns")
response.write cn2en(cns)

%>
