首页WEB开发ASP教程 → ASP编码转换函数GB2312转换UTF-8

ASP编码转换函数GB2312转换UTF-8

日期:2007-4-15 14:17:19 出处:其他转载 作者:不详 人气:

<%
Function chinese2unicode(Str)
        dim i
        dim Str_one
        dim Str_unicode
        For i=1 to len(Str)
                Str_one=Mid(Str,i,1)
                Str_unicode=Str_unicode&chr(38)
                Str_unicode=Str_unicode&chr(35)
                Str_unicode=Str_unicode&chr(120)
                Str_unicode=Str_unicode& Hex(ascw(Str_one))
                Str_unicode=Str_unicode&chr(59)
        Next
        chinese2unicode = Str_unicode
End Function
Response.Write ("<style type='text/css'>body,td,textarea,fieldset,input,button{font-size:12px;background-color: #D4D0C8;color: #5B5B5B;}a{color:#5B5B5B;}textarea{SCROLLBAR-HIGHLIGHT-COLOR: #D4D0C8;color: #808080;background-color: #D4D0C8;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;SCROLLBAR-SHADOW-COLOR: #D4D0C8;SCROLLBAR-3DLIGHT-COLOR: #D4D0C8;SCROLLBAR-TRACK-COLOR: #D4D0C8;SCROLLBAR-ARROW-COLOR: #D4D0C8;SCROLLBAR-BASE-COLOR: #D4D0C8;SCROLLBAR-DARKSHADOW-COLOR: #D4D0C8;}.noinp {font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;color: #808080;border: 0px solid #ffffff;background-color: #D4D0C8;text-decoration: none;background-repeat: repeat;background-position: top;}.line {border-top-width: 0px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px;border-top-style: none;border-right-style: none;border-bottom-style: solid;border-left-style: none;border-bottom-color: #AAAAAA;}.xline {border-top-width: 0px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px;border-top-style: none;border-right-style: none;border-bottom-style: dotted;border-left-style: none;border-bottom-color: #BBBBBB;}</style>")& vbCrlf& vbCrlf& vbCrlf
Response.Write ("<body onload=""document.form1.a.focus();"">")& vbCrlf
action = Request.QueryString("action")
Select Case action
        Case "do"
                Call doing()
        Case else
                Call mains()
End Select

'-----------------------------
Sub mains()
        Response.write "<fieldset style=""width:60%"" align=""center""><legend>Gb2312 - Utf-8</legend>"& vbCrlf
        Response.Write ("<form name=""form1"" method=post action='?action=do'><div align=center>")& vbCrlf
        Response.Write ("<textarea name='a' style='width:99%' rows='8' onkeyup=""document.form1.submit();"" onafterpaste=""document.form1.submit();""></textarea></div><br>")& vbCrlf
        Response.Write ("<div align=center><textarea id='b' style='width:99%' rows='8'></textarea><br></div>")& vbCrlf
        Response.Write ("<br> <input type='submit' value='开始转换'></form></fieldset>")& vbCrlf
End Sub
'-----------------------------
Sub doing()
        Response.write "<fieldset style=""width:60%"" align=""center""><legend>Gb2312 - Utf-8</legend>"& vbCrlf
        Response.Write ("<form name=""form1"" method=post action='?action=do'><div align=center>")& vbCrlf
        Response.Write ("<textarea name='a' style='width:99%' rows='8' onkeyup=""document.form1.submit();"" onafterpaste=""document.form1.submit();"">"&Request.Form("a")&"</textarea></div><br>")& vbCrlf
        Response.Write ("<div align=center><textarea id='b' style='width:99%' rows='8' onmouseover=""if(this.value.length!=0){docopy()}"" onFocus=""if(this.value.length!=0){docopy()}""></textarea><br></div>")& vbCrlf
        Response.Write ("<br> <input type='submit' value='开始转换'></form></fieldset>")& vbCrlf

        Response.Write ("<script>document.getElementById('b').innerHTML='"&server.htmlencode(chinese2unicode(Request.Form("a")))&"';")& vbCrlf
        Response.Write ("function docopy(){")& vbCrlf
        Response.Write ("document.getElementById('b').select();")& vbCrlf
        Response.Write ("js = document.getElementById('b').createTextRange();")& vbCrlf
        Response.Write ("js.execCommand('Copy');")& vbCrlf
        Response.Write ("document.getElementById('a').value='';")& vbCrlf
        Response.Write ("document.form1.submit();}")& vbCrlf
        Response.Write ("</script>")& vbCrlf

End Sub

%>

关于本站 | 帮 助 | 广告服务 | 版权声明 | 业务合作 | 捐助本站 | 软件发布 | 联系我们
77资源下载 www.77zy.com ©2007-2008 版权所有
备案编号:赣ICP备07002641号  QQ:674648476