首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 其它类文章 >
    7i24 .Com  
  在ASP/VBScript中用二进制数

7i24.Com不停为您服务
在ASP/VBScript中用二进制数

ASP (VBS) has only basic support for binary data. The data can be
created and accessed by 'B' string functions (ChrB, MidB,
InStrB...) :

Dim i, MyByteArray
For i=1 To 255
  MyByteArray = MyByteArray & ChrB(i)
Next
Response.Buffer = True
Response.ContentType = "Application/Crazzy"
Response.BinaryWrite MyByteArray

  You can also create convert function from String to binary :
Function StringToBinary(S)
 Dim i, ByteArray
 For i=1 To Len(S)
  ByteArray = ByteArray & ChrB(Asc(Mid(S,i,1)))
 Next
 StringToBinary = ByteArray
End Function

  And use the function :
Response.BinaryWrite StringToBinary("My first binary string.")


  You can work with binary data from BinaryRead by the same way :
  Binary = Request.BinaryRead(Request.ServerVariables
("HTTP_Content_Length"))
  bString = BinaryToString(Binary)
  Response.Write bString
  'Of course, you can use Response.BinaryWrite Binary :-)

Where BinaryToString is :
Function BinaryToString(Binary)
 Dim I, S
 For I = 1 To LenB(Binary)
  S = S & Chr(AscB(MidB(Binary, I, 1)))
 Next
 BinaryToString = S
End Function

  To save/retrieve binary data from disk, binary file upload and
download in ASP or better work with binary data (use different code
pages - ANSI, MAC, UTF, search binary data, etc.)
http://www.pstruh.cz/tips/detpg_BinASP.htm 


  2002年1月9日  阅读 1218 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 在 VBSript 中使用 regular expression 取得子字串
下一篇: asp 函數介紹-1
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利