Hi all,

I can't find a way to write arbitrary binary data in my response. I
have a big list of ints that I would like to serve in a response as
compact as possible. For this, I create an array of shorts (my ints
never take more than two bytes). I create my array like this:

from array import array

int_bytes = array('H')
for p in int_data:
        int_bytes.append(p)

later on, when I want to write the response, I do this:

self.response.out.write(int_bytes.tostring())

but I get this nasty error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position
0: ordinal not in range(128)

I understand from this that StringIO, of which self.response.out is an
instance, does not accept bytes that cannot be encoded to ascii.

Does anyone know how I can do to write this kind of binary data?

Thank you,

  Alfonso
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to