in reply to Converting Mainframe EBCDIC data
About 10 years ago I was receiving mainframe EBCDIC files to our Windows servers and converting them to ASCII with the simple script below. It was handy since it could be customized to any non-standard character set desired:
# e2a - convert an EBCDIC file to ASCII. @E2A = qw( 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D F8 2F F8 F8 32 33 34 35 36 37 38 39 3A 3B 3C 3D F8 3F 20 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 3C 28 2B 7C 26 F8 F8 F8 F8 F8 F8 F8 F8 F8 21 24 2A 29 3B 5E 2D 2F F8 F8 F8 F8 F8 F8 F8 F8 7C 2C 25 5F 3E 3F F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 3A 23 40 27 3D 22 F8 61 62 63 64 65 66 67 68 69 F8 F8 F8 F8 F8 F8 F8 6A 6B 6C 6D 6E 6F 70 71 72 F8 F8 F8 F8 F8 F8 F8 7E 73 74 75 76 77 78 79 7A F8 F8 F8 5B F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 F8 5D F8 F8 7B 41 42 43 44 45 46 47 48 49 F8 F8 F8 F8 F8 F8 7D 4A 4B 4C 4D 4E 4F 50 51 52 F8 F8 F8 F8 F8 F8 5C F8 53 54 55 56 57 58 59 5A F8 F8 F8 F8 F8 F8 30 31 32 33 34 35 36 37 38 39 F8 F8 F8 F8 F8 F8 ) ; open (FILE, $ARGV[0]) or die "Can't read $ARGV[0]: $! "; while (<FILE>) { s/(.)/chr(hex($E2A[ord($1)]))/eg; print; }
|
|---|