Flavio Grossi added the comment:

Hi, and thank you for your answer.

However this is not strictly related to the newline, but also to some small 
idiosyncrasies and different behavior among py2 and py3 (and even in py2 using 
Header() or Charset()):

# py2.7, non-unicode str
>>> H('test', 'utf-8').encode()
'=?utf-8?q?test?='

>>> Charset('utf-8').header_encode('test')
'=?utf-8?q?test?='


# py2.7, unicode str
>>> H(u'test', 'utf-8').encode()   # this is the only different result
'test'

>>> Charset('utf-8').header_encode(u'test')
u'=?utf-8?q?test?='



# py3.4, unicode
>>> H('test', 'utf-8').encode()                                            
'=?utf-8?q?test?='                                                      
                
# py3.4, bytes                                                                
>>> H(b'test', 'utf-8').encode()                                             
'=?utf-8?q?test?='


As you can see, the only when using unicode strings in py2.7 no header encoding 
is done if the unicode string contains only ascii chars.

----------

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

Reply via email to