|
发表于 2006-2-12 01:09:26
|
显示全部楼层
呵呵,浏览你发的《AT指令集》的UCS2字母表,可打印的ASCII字符应该是用00+HEX表示的。以下是一个带VBScript的HTML,使用IE5以上的浏览器就可以运行了,可以处理UCS2字母表的内容,不过VB6不能运行。
把下面内容贴成HTML文件即可:
<HTML>
<HEAD>
<TITLE>Unicode字符-编码转换</TITLE>
<META http-equiv=Content-type content="text/html; charset=gb2312">
<META NAME="Author" CONTENT="FengGuoHui">
</HEAD>
<BODY>
<table>
<tr><td>字符串:</td><td><input size=50 id=srcstr></input>
<input type=button value="到编码..." onclick="StrToUni()"></input></td></tr>
<tr><td>编码:</td><td><input size=50 id=dscstr></input>
<input type=button value="到字符串..." onclick="UniToStr()"></input></td></tr>
</table>
</BODY>
</HTML>
<Script Language="vbscript">
Sub StrToUni()
mstr = srcstr.value
For i = 1 to Len(mstr)
masc = Mid(mstr,i,1)
If Asc(masc)<0 Then
masc = Replace(escape(masc),"%","")
masc = Replace(masc,"u","")
masc = Right("0000" & masc,4)
else
masc = Right("0000" & Hex(Asc(masc)),4)
End If
mtstr = mtstr & masc
Next
dscstr.value = mtstr
End Sub
Sub UniToStr()
Dim mstr, mtstr, i, masc
mstr = dscstr.value
For i = 1 to Len(mstr) Step 4
masc = Mid(mstr,i,4)
If Left(masc,2)<>"00" Then
masc = "u" & masc
Else
masc = Right(masc,2)
End If
mtstr = mtstr & unescape("%" & masc)
Next
srcstr.value = mtstr
End Sub
</Script>
-----此内容被favr于2006-02-12,01:12:49编辑过 |
|