TL;DR: Is there a way to properly encode received bytes using EBCDIC ?
Hello,
while working with sockets I noticed that python always expects and EBCDIC string.
I have currently been able to get a Python client-server configuration (Linux client, z/OS server) to communicate by forcing the client to use ‘cp500’ encoding, but I haven’t been able to do the same server-side (decoding Latin-1 to EBCDIC).
This is what I tried up until now:
>>> import codecs, sys
>>> test = ‘\x48\x54\x54\x50’
>>> test.encode(‘cp500’)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x48 in position 0: ordinal not in range(128)
I also tried by setting the default encoding to ‘cp500’ with:
>>> reload(sys)
>>> sys.setdefaultencoding(‘cp500’)
>>> test.decode(‘Latin1’)
u’\x48\x54\x54&’
Still, without success.
Any hints?