Specifications

4-37
Printer, Plotter, and Spooler Subsystem Programming
Printer Code Page Translation Tables
Translation of code points in the print file to code points for the printer is a two–stage
process (translation of code points for Oriental languages is handled differently). The first
stage translates code points from the print file to code points in an intermediate code page.
The intermediate code page consists of 16–bit integer code points for all supported
characters. The intermediate code page is defined in the /usr/lib/lpd/pio/etc/codepage.txt
file.
Stage–1 Translation
The example C language code shown 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.
Stage–2 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