User`s guide

4-36
Guide to Printers and Printing
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 printers 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.
Printer Code Page Translation for Multibyte Code Sets
Multibyte code set (MBCS) translation from the print file to the code set differs from
translation for single–byte code set (SBCS) code points. Translation from print file to code
set in multibyte environments is a two–stage process.
During the first stage of code–set translation, the input code set of the print file is translated
to a process code set. The process code set must be one of the MBCS code sets supported
by the iconv subroutine and locale database (DB), examples include the IBM–932,
IBM–eucTW, and IBM–eucKR code sets. During the second stage, the process code set is
translated to an appropriate output code set for the printer. The iconv subroutine translates
the code set, if the iconv converter for the translation exists. When the input or output code
set and process code are the same, no code–set translation is performed.