New submission from Sworddragon:

I have made some tests with encoding/decoding in conjunction with 
unicode-escape and got some strange results:

>>> print('ä')
ä
>>> print('ä'.encode('utf-8'))
b'\xc3\xa4'
>>> print('ä'.encode('utf-8').decode('unicode-escape'))
ä
>>> print('ä'.encode('utf-8').decode('unicode-escape').encode('unicode-escape'))
b'\\xc3\\xa4'
>>> print('ä'.encode('utf-8').decode('unicode-escape').encode('unicode-escape').decode('utf-8'))
\xc3\xa4


Shouldn't .decode('unicode-escape').encode('unicode-escape') nullify itself and 
so "'ä'.encode('utf-8').decode('unicode-escape').encode('unicode-escape')" 
return the same result as 'ä'.encode('utf-8')?

----------
components: Unicode
messages: 217021
nosy: Sworddragon, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Reversing an encoding with unicode-escape returns a different result
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21331>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to