classification
Title: encode UTF-16 generates unexpected results
Type: behavior Stage: resolved
Components: Unicode Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: anders.rundgren.net@gmail.com, ezio.melotti, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2018-03-26 09:26 by anders.rundgren.net@gmail.com, last changed 2018-03-26 12:52 by anders.rundgren.net@gmail.com. This issue is now closed.

Messages (3)
msg314443 - (view) Author: Anders Rundgren (anders.rundgren.net@gmail.com) Date: 2018-03-26 09:26
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> v = '\u20ac'
>>> print (v)
€
>>> v.encode('utf-16')
b'\xff\xfe\xac '
>>> v.encode('utf-16_be')
b' \xac'

I had expected to get pair of bytes with 20 AC for the € symbol
msg314445 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-26 10:22
b'\x20' is the same as b' '.
msg314451 - (view) Author: Anders Rundgren (anders.rundgren.net@gmail.com) Date: 2018-03-26 12:52
Thanx for the superquick response!
I really appreciate it.

I'm obviously a Python n00b

Anders
History
Date User Action Args
2018-03-26 12:52:59anders.rundgren.net@gmail.comsetmessages: + msg314451
2018-03-26 10:22:29serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg314445

resolution: not a bug
stage: resolved
2018-03-26 09:26:20anders.rundgren.net@gmail.comcreate