win32 binary data manipulation in ASP

Mark Hammond mhammond at skippinet.com.au
Sun Dec 19 19:43:44 EST 1999


"Joe Smith" <JoeSmith at bogusaddress.com> wrote in message
news:385CC64E.25E91136 at bogusaddress.com...
>
> I am trying to write a server side ASP script in python.
>
>     buffer = os.read(fd, numBytes)
>     Response.BinaryWrite(buffer)
>
> I notice that I am getting exactly double the number of bytes on
output.  I
> suspect that the string returned from os.read() is getting converted
to
> unicode.
>
> I am looking for a way to convert the string to an array of bytes,
not an array
> of unicode characters.

If you have build 127 of win32all, you can use a buffer object.  eg:

   data = os.read(fd, numBytes)
   Response.BinaryWrite(buffer(data))

[ie, note that "buffer" is a Python builtin, so the variable name was
changed]

This also depends on ASP accepting data in this format - Im guessing
it will, but I dont know for sure...

Mark.






More information about the Python-list mailing list