--2007-6-18 18:56:26
GB2312转换UTF-8的文件
现在中文的程序都是GB2312的,这样对程序的推广很有限制的,因为GB2312只能用语中文,而不能支持其他语言,所以我把我自己作的转换文件献给大家,希望大家以后做程序一定用UTF-8编。。。[Copy to clipboard]CODE:
<%
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
%>
演示:http://www.alyar.cn/code/Gb-Utf.asp
相关内容
下列内容与转换有着内在的联系,建议您一并阅读。