Binary data handling ?

Mark Hahn mark at hahnca.com
Fri Aug 29 15:54:21 EDT 2003


What you are trying to do in general won't work.  Any combination of 0x0d0a
that was in the original data will be corrupted by your code.  There is no
way to "fix" the data once the web server has corrupted it.

"Bill Loren" <lorenb2 at bezeqint.net> wrote in message
news:mailman.1062079383.31727.python-list at python.org...
> Hello ppl,
>
> I'm having difficulties to accomplish some simple chores with binary data.
> I'm having a string (?) which I received via an HTTP transactions which is
a
> binary file.
> Problem is the webserver I'm communicating with injected a \x0D before
every
> \x0A,
> and I need to remove those 0x0D characters from my buffer before saving it
> to disk.
>
> any ideas ?
>
> I tried the following without any success:
> string.replace("%c%c" % (13,10), "%c" % (10))
> string.replace("\x0d\x0a", "\0x0a")
>
> thx
> ~B
>
>






More information about the Python-list mailing list