阶段 1 打印机代码页转换
代码页转换的第一阶段产生中间代码页。
下面显示的示例生成第一阶段的转换表,它将假设的代码页 123 的代码点转换为中间代码页。
#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);
}代码点 252 处的 CP 表示代码点应被不加更改地复制。 代码点 253 处的 SC 表示字符未在中间代码页中定义,
因此将打印一个替换字符。 位于代码点 254 的 126 表示应该将代码点 254 转换为代码点 126。
qprt 命令中的 -X 标志指定打印文件的代码页名称。 当此值为 123 时,格式化程序将从 /usr/lib/lpd/pio/trans1/123 文件中读取表,并将其用于 stage-1 转换。