I have the following code:
u"[%s] - %s" % (a, b.encode('utf-8'))
Where a is a unicode string and b is a classical str
Now this gives the classical error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 2: ordinal not in range(128)
(Position 2 belongs to a)
Why doesn't this work? I thought that if I make string b an unicode string, then it should n't have to convert to ascii when joining the strings together?
b.decode("utf-8"), to convertbbytestring to Unicode. In general, bytes -> decode() -> Unicode -> encode() -> bytes.