Stage two printer code page translation
In the second stage of code point translation, one or more stage-2 translation tables convert code points from the intermediate code page to those appropriate for the printer.
The t0 - t9 attributes in the database colon file specify the full path names of stage-2 translation tables. Each of the t0 - t9 attributes can specify multiple stage-2 translation tables by separating the names with commas. The print formatter reads in the stage-2 translation tables and chains them into a ring. Beginning with the table for the current printer code page, the formatter processes each character in the input print file. The first determination is whether the character is defined in that printer code page. In other words, the code point value is not larger than the number of code points in the table, and the value is not SC.
If the character is in the code page, the translated code point is sent to the printer. The formatter selects the printer code page by sending the appropriate printer command string. By convention, the printer command string's 2-character attribute name is at index 0 in the Command Names array. If the character is not in the code page, the formatter repeats the process for the next stage-2 translation table in the ring. If the formatter cannot find a translation table in the ring that can print the character, it prints a substitute character (underscore) instead.
The following example C language code generates a stage-2 translation table named XYZ.999, which translates code points from the intermediate code page to code points for the printer's code page. The c1 attribute is assumed to contain the printer command string that will cause the printer to select code page XYZ.999.
#include <piostruct.h>
#include <fcntl.h>
/*** Table to Translate Code Points for the Intermediate ***/
/*** Code Page to Code Points for a Printer Code Page ***/
struct transtab table[] = {
/* 00 (000) */ {CP}, {CP}, {CP}, {CP},
.
.
.
/* FC (252) */ {63}, {CP}, {94,1}, {SC} };
/*** Command Names for the Translate Table ***/
char cmdnames[][2] = {
{'c', '1'}, /* index 0 - select the code page */
{'e', 'b'} }; /* index 1 - next byte is graphic */
/*** Write the Table To a File (Error Processing Not Shown) ***/
main() {
int fildes;
int num_commands = sizeof(cmdnames) / 2;
fildes = open("/usr/lib/lpd/pio/trans2/XYZ.999", O_CREAT |
O_WRONLY,\ 0664);
write(fildes, "PIOSTAGE2XLATE00", 16);
write(fildes, &num_commands, sizeof(num_commands));
write(fildes, cmdnames, sizeof(cmdnames));
write(fildes, table, sizeof(table));
return(0);
}
The {63}
at code point 252 means that code point 252 should
be translated to code point 63 before being sent to the printer. The {CP}
at
code point 253 means that code point 253 should be sent to the printer with
no translation. The {94,1}
at code point 254 means that code
point 254 should be translated to code point 94 before it is sent to the printer.
The ,1
in {94,1}
indicates that the printer
command string whose 2-character attribute name is at index 1 in the Command
Names array should be sent to the printer before sending the code point. The SC
at
code point 255 indicates that the character at code point 255 in the intermediate
code page cannot be printed by the printer code page described by this stage-2
translation table.