[Tutor] Creating a unicode string from bytes and % opperator
Wesley Brooks
wesbrooks at gmail.com
Mon Jul 28 11:16:47 CEST 2008
Dear Users,
I'm trying to create a unicode character from two bytes. Unfortunatly
I'm getting a "UnicodeDecodeError". Can some one please suggest an
alternative way of doing what's bellow? In the example bellow the two
bytes have been converted into a string hex value, but they could just
as easily be an integer or binary value if either is easier to deal
with.
Python 2.4.3 - Enthought Edition 1.0.0 (#69, Aug 2 2006, 12:09:59) [MSC v.1310
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u"\u%s%s" %('0d', 'fe')
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-2: tr
uncated \uXXXX escape
>>>
Cheers,
Wesley Brooks.
More information about the Tutor
mailing list