[Python-bugs-list] Empty unicode string as utf-16 (PR#393)

lhudson@geminidataloggers.com lhudson@geminidataloggers.com
Fri, 7 Jul 2000 05:59:20 -0400 (EDT)


Full_Name: Lawrence Hudson
Version: 1.6a2
OS: Win2k Professional
Submission from: mailhost.oriongroup.co.uk (194.200.199.161)


Encoding an empty unicode string as utf-16 produces some unusual results:

Python 1.6a2 (#0, Jun 30 2000, 16:33:35) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a = u''
>>> a.encode('utf-16')
'\007\000'
>>> a.encode('utf-16')
'ut'
>>> a.encode('utf-16')
'ut'
>>> a.encode('utf-16')
'ut'
>>>
>>>
>>> a.encode('utf16')
'\007\000'
>>> a.encode('utf16')
'ut'
>>> a.encode('utf16')
'ut'
>>>
>>>
>>> a.encode('utf-16-le')
''
>>> a.encode('utf-16-le')
''
>>>
>>>
>>> a.encode('utf-16-be')
''
>>> a.encode('utf-16-be')
''
>>>
>>>