Solved

Request.BinaryRead - parse results

Posted on 2004-09-15
3
829 Views
Last Modified: 2008-02-01
I need to know how to parse and manipulate the results of BinaryRead obtained like so:

ByteCount            = Request.TotalBytes
BinaryBuffer      = Request.BinaryRead(ByteCount)

I need to convert BinaryBuffer into a string, manipulate it, and then convert it back into a format in which i can do:

Response.BinaryWrite(MyModifiedBinaryBuffer)

Any ideas?
0
Comment
Question by:SweatCoder
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
deighc earned 500 total points
ID: 12072923
Try these functions. To use:

strBinaryRequest = RSBinaryToString(Request.BinaryRead(Request.TotalBytes))

------------------------------------------------------------------------------------------------

Function RSBinaryToString(xBinary)
      Dim Binary
      'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
      If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary
        
      Dim RS, LBinary
      Const adLongVarChar = 201
      Set RS = CreateObject("ADODB.Recordset")
      LBinary = LenB(Binary)
        
      If LBinary>0 Then
            RS.Fields.Append "mBinary", adLongVarChar, LBinary
            RS.Open
            RS.AddNew
            RS("mBinary").AppendChunk Binary
            RS.Update
            RSBinaryToString = RS("mBinary")
      Else
            RSBinaryToString = ""
      End If
End Function

Function MultiByteToBinary(MultiByte)
      Dim RS, LMultiByte, Binary
      Const adLongVarBinary = 205
      Set RS = CreateObject("ADODB.Recordset")
      LMultiByte = LenB(MultiByte)
      If LMultiByte>0 Then
            RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
            RS.Open
            RS.AddNew
            RS("mBinary").AppendChunk MultiByte & ChrB(0)
            RS.Update
            Binary = RS("mBinary").GetChunk(LMultiByte)
      End If
      MultiByteToBinary = Binary
End Function
0
 
LVL 15

Expert Comment

by:deighc
ID: 12072932
.... note that this just leaves you with a string - not a binary stream. You could use Response.write to output the result to the browser.
0
 
LVL 11

Author Comment

by:SweatCoder
ID: 12075479
i posted this late last night and, as expected, didn't get an immediate response, so i ended up having success doing it this way:

BinaryBuffer = Request.BinaryRead(Request.TotalBytes)
' Convert the binary data to ASCII
FOR counter = 1 TO LENB(BinaryBuffer)
    PostedData = PostedData & Chr(AscB(MidB(BinaryBuffer, counter,1)))
NEXT

. . .but i'm wondering if there's a way to do this without a FOR loop that traverses over every character in the binary stream. just convert the binary stream to a text stream without looping through, just for efficiency.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grab data from remote page 10 61
Update table value with join syntax 2 60
Field that has HTML displays the code instead of the text in html 16 64
SP to delete duplicates 15 62
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now