Previous Topic Next topic Print topic


Using the EBCDIC Character Set

The Open PL/I compiler and run time support character data encoded in EBCDIC format as well as ASCII format. For EBCDIC, this essentially means that the user program understands all character data as EBCDIC. Humans see all character data as readable text when it is read from input devices and written to display devices. When EBCDIC data is written to a file or read from a file, the data is always encoded as EBCDIC

Compiling a program in EBCDIC mode does not mean that the source file is in EBCDIC format. The source file is always in ASCII format, and character string literals such as 'abc' are converted to EBCDIC by the compiler. Run time support in EBCDIC mode likewise maintains all character data in EBCDIC format, and only translates to and from ASCII for human readable input or output devices.

For any given program, it is expected that all modules are compiled in either ASCII mode or EBCDIC mode.

The following compiler switches are supported:

-ascii all character data in the user program is stored in ASCII format (default)
-ebcdic all character data in the user program is stored in EBCDIC format

These examples show how the compiler treats character data in EBCDIC mode:

'abc' stored as 0x818283
'abc ' stored as 0x81828340
'abc 'E stored as 0x81828340
'abc 'A stored as '0x61626320
dcl s char (4) init (''); stored as 0x40404040
dcl s char (4) init (''E); stored as 0x40404040 (''E the null string padded with 4 EBCDIC spaces 0x040)
dcl s char (4) init (''A); stored as 0x40404040 (''A the null string padded with 4 EBCDIC spaces 0x040)

These examples show how the compiler treats character data in ASCII mode:

'abc' stored as 0x616263
'abc ' stored as 0x61626320
'abc 'E stored as 0x81828340
'abc 'A stored as '0x61626320
dcl s char (4) init (''); stored as 0x20202020
dcl s char (4) init (''E); stored as 0x20202020 (''E the null string padded with 4 ASCII spaces 0x020)
dcl s char (4) init (''A); stored as 0x20202020 (''A the null string padded with 4 ASCII spaces 0x020)
Note: In the above examples, the postfix characters for "E and "A are superfluous because the null string is padded with spaces accordingly with EBCDIC or ASCII mode.

When compiling in EBCDIC or ASCII mode through a server, output is dependent on the MF_CHARSET setting on the server. This table shows expected output formats of SYSPRINT for EBCDIC or ASCII-compiled programs based on the MF_CHARSET setting on the server.

Program Compiled Server Running As DCB Expected Format of SYSPRINT
ASCII ASCII SYSOUT=* ASCII
EBCDIC EBCDIC SYSOUT=* EBCDIC
ASCII ASCII SYSOUT=*,DCB=(RECFM=LSEQ) ASCII
EBCDIC EBCDIC SYSOUT=*,DCB=(RECFM=LSEQ) ASCII
ASCII EBCDIC SYSOUT=*,DCB=(RECFM=LSEQ) ASCII

Note that EBCDIC datasets are in EBCDIC and display correctly in ESMAC. LSEQ Datasets are flipped to ASCII and display correctly in ESMAC

Previous Topic Next topic Print topic