The standard Fcopy utility of MPE has options for converting entire records from EBCDIC to ASCII and vice-versa. Below are the commands to copy from an IBM tape to an ASCII disc file, converting EBCDIC fields in columns 3 through 7 (first byte is 1) and columns 14 through 27, then convert it back again.
>from=*tape;to=dfile;EBCDICIN=(3:7;14:27) >from=dfile;to=*tape;EBCDICOUT=(3:7;14:27)
Robelle's Suprtool utility also has options for converting data. Use the $ETOA or $ATOE functions of the Extract command to convert specific fields from EBCDIC to ASCII or vice versa. These functions take a single byte-type field as a parameter, either an actual database field (unlikely!) or a Defined field. For example:
>input *tape >define custname,1,20 >define rest-of-data,21,30 >extract $etoa(custname),rest-of-data >output dfile >xeq
On HP-UX, you can write a program to call HP's nltranslate routine to translate ASCII arrays to EBCDIC, or use the dd program.
According to Randy Medd HP's ASCII-to-EBCDIC translation is not the same as that used by IBM documented in the IBM 3780 manual. HP's translation is different for four printable characters (among others.) Specifically:
HP: | ASCII | EBCDIC |
---|---|---|
"!" | 0x21 | 0x4F |
"[" | 0x5B | 0x4A |
"]" | 0x5D | 0x5A |
"^" | 0x5E | 0x5F |
IBM: | ASCII | EBCDIC |
---|---|---|
"!" | 0x21 | 0x5A |
"[" | 0x5B | 0xB0 |
"]" | 0x5D | 0xBB |
"^" | 0x5E | 0xBA |
The major confusion arises with the "!" and "]" characters, as they translate to similar values. The rest of the differences resolve themselves in the range of non-printing characters.
Conversion problems often occur when doing EDI transmissions. Non-alphanumeric characters are often used as delimiters, and sometimes change due to these table differences. In addition, there is a third variant, used by AT&T.
AT&T: | ASCII | EBCDIC |
---|---|---|
"!" | 0x21 | 0x5A |
"[" | 0x5B | 0xAD |
"]" | 0x5D | 0xBD |
"^" | 0x5E | 0x5F |
If you're using the CTRANSLATE intrinsic in your MPE programs, then you're using the "HP" table. For HP-UX, the dd program does translations as well, but dd uses the AT&T tables! To quote the HP-UX manual:
ASCII and EBCDIC conversion tables are taken from the 256-character ACM standard, Nov, 1968. The IBM conversion, while less widely accepted as a standard, corresponds better to certain IBM print train conventions. There is no universal solution. (Emphasis added.)