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

mal@lemburg.com mal@lemburg.com
Fri, 7 Jul 2000 06:52:05 -0400 (EDT)


lhudson@geminidataloggers.com wrote:
> 
> 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')
> ''
> >>>
> >>>

Thanks. I'll checkin a patch which resolves this later today.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/