Handling Variant byte array in ASP

This is yet another of slightly undocumented ASP features - you can find a lot of examples telling you how to read and write binary data (with, among other things, Response.binaryWrite or ADODB_recordset("blob").value), but when you try to manipulate individual bytes (I had to compute MD5 hash), uncle Google or Microsoft search gives you nothing.

The trick is (as always) very simple: you treat variant byte array as string, using regular string functions (like Len, Mid or Asc). However, due to Unicode support in VBScript, you have to use their byte versions. So, to dump the variant byte array, use this code:

For I = 1 to LenB(varArray)
Response.Write AscB(MidB(varArray,I,1))
Next

1 comment:

Anonymous said...

THANK YOU !!!

That solved my problems.

Post a Comment