Message183783
I do not see any bug. Unicode chars do not have an encoding (except internally) The .encode() method encodes the the unicode string to a byte string. It does *not* mutate the string. Since you do not bind the byte string to anything, it disappears. Compare
>>> c = u'\u20ac'
>>> b = c.encode()
>>> c
'€'
>>> b
b'\xe2\x82\xac'
Now you have both the unicode string and the utf-8 encoded byte string that represents the char.
>>> b.decode()
'€'
If you have any more questions, please reread the tutorial or ask on python-list or even the tutor list. Also post there about any 'problems' you find. |
|
Date |
User |
Action |
Args |
2013-03-09 02:25:07 | terry.reedy | set | recipients:
+ terry.reedy, ezio.melotti, pradyunsg |
2013-03-09 02:25:07 | terry.reedy | set | messageid: <1362795907.55.0.317231526287.issue17348@psf.upfronthosting.co.za> |
2013-03-09 02:25:07 | terry.reedy | link | issue17348 messages |
2013-03-09 02:25:07 | terry.reedy | create | |
|