Stage one printer code page translation

An intermediate code page is produced during the first stage of code page translation.

The example below generates a stage-1 translation table to translate code points from a hypothetical Code Page 123 to the intermediate code page.

#include <piostruct.h>
#include <fcntl.h>
/*** Table to Translate Code Points for Input Code Page ***/
/*** "123" to Code Points for the Intermediate Code Page    ***/
short table[256] = {
/* 00 (000) */ CP, CP, CP, CP,
.
.
.
/* FC (252) */ CP, SC, 126, CP };
/*** Write the Table to a File (Error Processing Not Shown) ***/
main ( ) {
int fildes;
int fmt_type = 1;
fildes = open("/usr/lib/lpd/pio/transl/123", O_CREAT | O_WRONLY,\
0664);
write(fildes, "PIOSTAGE1XLATE00", 16);
write(fildes, &fmt_type, sizeof(fmt_type));
write(fildes, table, sizeof(table));
return(0);
}

The CP at code point 252 means that the code point should be copied with no change. The SC at code point 253 means the character is not defined in the intermediate code page and so a substitute character should be printed instead. The 126 at code point 254 means that code point 254 should be translated to code point 126.

The -X flag in the qprt command specifies the print file's code page name. When this value is 123, the formatter reads the table from the /usr/lib/lpd/pio/trans1/123 file and uses it for stage-1 translation.