当前位置: 代码迷 >> ASP >> 怎么将asp代码转为ascii码
  详细解决方案

怎么将asp代码转为ascii码

热度:137   发布时间:2012-02-24 16:30:39.0
如何将asp代码转为ascii码?
RT,可以做到把代码变成象chr(60)&chr(102)&chr(111)&chr(114)&chr(109)这样?应该不会是手工输入吧。是不是有什么工具可以做到自动转换呢?
谢谢!

------解决方案--------------------
dim s, l, i, s2
s = "abc中国人 "
s = getText( "c:\cmd.txt ")
l = len(s)
i = 1
s2 = " "
while (i <= l)
s2 = s2 & "chr( " & AscB(mid(s, i, 1)) & ")& "
i = i + 1
wend
if s2 <> " " then s2 = left(s2, len(s2)-1)
msgbox s2
writeText s2, "c:\cmd2.txt "


Function writeText(str, path)
Dim fs, fsowrite
On Error Resume Next
Set fs = CreateObject( "Scripting.fileSystemObject ")
Set fsowrite = fs.CreateTextFile(path, True)
fsowrite.Write str
fsowrite.Close
Set fsowrite = Nothing
Set fs = Nothing
If Err.number <> 0 Then
msgbox Err.Description & ",不支持FSO。 "
End If
End Function

Function getText(path)
Dim fso, objfile, content
content = " "
On error Resume Next
Set fso = CreateObject( "Scripting.fileSystemObject ")
If fso.FileExists(path) Then
Set objfile = fso.OpenTextFile(path, 1, False)
If Not objfile.AtEndOfStream Then
content = objfile.ReadAll
End If
objfile.Close
Set objfile = Nothing
End If
Set fso = Nothing
If Err.number <> 0 Then
msgbox Err.Description & ",不支持FSO。 "
End If
getText = content
end Function
  相关解决方案