[Robelle] [SmugBook] [Index] [Prev] [Next]

EBCDIC Characters for MPE Users

The MPE operating system uses the ASCII character set, not the EBCDIC character set. IBM adopted EBCDIC from punched card codes in the early 1960s and still uses it on mainframes. It exists in at least six versions and has features such as non-contiguous letter sequences, control code values from 0 to 63, and the absence of several ASCII punctuation marks. However, when transferring data to or from IBM systems you will often encounter data that is in EBCDIC.

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:

Text version

HP: ASCII EBCDIC
"!"0x210x4F
"["0x5B0x4A
"]"0x5D0x5A
"^"0x5E0x5F

Text version

IBM:ASCIIEBCDIC
"!"0x210x5A
"["0x5B0xB0
"]"0x5D0xBB
"^"0x5E0xBA

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.

Text version

AT&T:ASCIIEBCDIC
"!"0x210x5A
"["0x5B0xAD
"]"0x5D0xBD
"^"0x5E0x5F

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.)


[Robelle] [SmugBook] [Index] [Characters] [Prev] [Next]