I have a function that should receive data in hex EBCDIC format and convert it to ASCII.
For example, transforming the data, F1F1F0F0 should give me a 1100 in ASCII, or 31313030 in hex ASCII.
What I've found is this:
def __decode_ASC_EBCDIC_DT(self, data):
if (data[0] == '3'):
#HEX ASCII
dt_ = ''.join(chr(int(data[i:i + 2], 16)) for i in range(0, len(data), 2))
return dt_
elif (data[0] == 'F'):
#HEX EBCDIC
try:
tmp = bytearray(ord(c) for c in data)
dt_ = ''.join(tmp.decode('cp500'))
except:
print('can\'t convert:' + data)
return dt_
but it seems that CP500 is transfroming my data in 'ãããã' and in this case this is incorrect. (tmp is correct bytearray(b'F1F1F0F0'))
Any ideas, or should I make my own dictionary for EBCDIC?