Problem with struct.unpack

Kuner Martin martin.kuner at
Fri Jul 1 12:53:25 CEST 2005

Hi all,

I have the following question/problem:

>>> import struct
>>> strBuffer = u'\x00\xf0\x00\x00\x00\x00\x00\x00'
>>> print "%r" % strBuffer
>>> (doorOpen,) = struct.unpack("1x1B6x", strBuffer)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf0' in
position 1: ordinal not in range(128)

Why is that not working with an "u" string ?
If there is a 0x70 on the second byte, it works.

Any ideas ?

Thanks in advance


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list