[New-bugs-announce] [issue30586] Encode to EBCDIC doesn't take into account conversion table irregularities

Vladimir Filippov report at bugs.python.org
Wed Jun 7 07:41:40 EDT 2017


New submission from Vladimir Filippov:

These 4 symbols were encoded incorrectly to EBCDIC (codec cp500): "![]|". Correct table of conversation for these symbols described in https://www.ibm.com/support/knowledgecenter/SSZJPZ_11.3.0/com.ibm.swg.im.iis.ds.parjob.adref.doc/topics/r_deeadvrf_Conversion_Table_Irregularities.html

This code:
--------------------
ascii = '![]|';
print("ASCII:  " + bytes(ascii, 'ascii').hex())
res = ascii.encode('cp500')
print ("EBCDIC: " +res.hex())
--------------------
on Python 3.6.1 produce this output:
--------------------
ASCII:  215b5d7c
EBCDIC: 4f4a5abb
--------------------

Expected encoding (from IBM's table):
! - 5A
[ - AD
] - BD
| - 4F

Workaround: use this translation after encoding
bytes.maketrans(b'\x4F\x4A\x5A\xBB', b'\x5A\xAD\xBD\x4F')

----------
components: Unicode
messages: 295329
nosy: Vladimir Filippov, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Encode to EBCDIC doesn't take into account conversion table irregularities
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30586>
_______________________________________


More information about the New-bugs-announce mailing list