[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Guide to Printers and Printing

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.

The Ti and To attributes in the printer-dependent colon files define the possible flow of the translating code set. The Ti attribute specifies the combination of the input and process code sets:

[Input_code_set, ... ]Process_code_set, ...

The To attribute specifies the combination of the process and output code:

Process_code_set [Output_code_set0, Output_code_set1,
Output_code_set2, Output_code_set3,... ], ...

For example, the To attribute for a Japanese printer is defined as:

::To::IBM-932[IBM-932, IBM-932, IBM-932], ibm-eucJP[IBM-932,
IBM-932, IBM-932,IBM-932]

All characters of the character set ID (CSID) are printed using ROM fonts when an output code set is specified for each CSID. Otherwise, bitmap images from the Xwindows font are used. The type of Xwindows font files, including the font image of each CSID, is selected by reading a file from the /usr/lib/X11/nls directory.

Printer Code Page Translation Tables for Multibyte Code Sets

A translation table consists of maps between code points that are not shared by the two code sets. A printer backend can communicate with other code sets even if the code set is not supported by the iconv subroutine by using a translation table provided in the /usr/lib/lpd/pio/transJP directory.

When an input or an output code set is not supported by the iconv subroutine, the unsupported code set translates one of the code sets that are supported or directly to a process code set using the translation tables found in the /usr/lib/lpd/pio/transJP directory. Users with root authority can add new code sets for printers by creating translation tables.

The naming convention for new translation tables is FromCodeSetName_ToCodeSetName. All translation tables must be defined in the trans_dir file. The f_cp from code point in a translation table must be sorted in alphabetical order in advance.

The trans_dir and codeset.alias files are in the /usr/lib/lpd/pio/transJP directory. The trans_dir file format is:

FromCodeSetName ToCodeSetName NameofTranslationFile

Code set aliases are defined in the codeset.alias file. The codeset.alias file format is:

CodeSetName AliasName ...

For example, to print an MBCS file that was written with a new code set on an IBM-932 printer follow these steps:

  1. Create a translation table in the /usr/lib/lpd/pio/transJP directory. The naming convention for the new file is NewCodeSetName_IBM-932.
  2. Define the translation table in the trans.dir file. The format to define a new code set named NewCodeSet is:
    newcodeset IBM-932 newcodeset_IBM-932
  3. Define the alias name in the trans.alias file, if needed.
  4. Append the code set name as input code in a colon file, for example:
    ::Ti::[NewCodeSetName, ...]IBM-932, ...

Using Xwindows Fonts with the qprt Command

MBCS printer backends use Xwindows fonts defined in the /usr/lib/X11/fonts directory to print characters that are not stored in the ROM of the printer. The -F and -I (uppercase i) flags for the qprt command designate Xwindow fonts for the printer. The default value of these qprt command options are specified in the colon files as the value of the _F and _I attributes.

The qprt -F flag specifies a font. The full path name, font alias, or the Xwindow Logical Function Description (XLFD) of an Xwindow font can be used with the -F flag.

The -I flag follows a font path to find the Xwindow fonts and creates the _I attribute entry. The colon file format for the _I attribute is:


If the user specifies another font path with the qprt -I command, the printer backend looks in the specified font path not in the default paths listed in the _I colon file. If the -I option has a null value, the backend assumes the default /usr/lib/X11/fonts directory.

To specify a specific Xwindows font file using a full path name, font alias, or XLFD, enter:

$ qprt -F '*-27-*-ibm_udcjp' foo.txt    /* XLFD names list */
$ qprt -F IBM_JPN17                     / * Font alias name */

This example directs the MBCS printer backend to look in the fonts.alias and fonts.dir files to find the appropriate fonts for the code set specified with the -X option of the qprt command.

Translation Table Example

#include <fcntl.h>
struct trans_table              /*Translation Table Structure  */
       unsigned int reserv1;    /* Reserved                    */
       unsigned int f_cp;       /* From code point             */
       unsigned int reserv2;    /* Reserved                    */
       unsigned int t_cp;       /* To code point               */
*Table to translate code points for input code set(NewCodeSet)
*to code points for the process code set(IBM-932).
struct trans_table table[] = 
        /*  ....    */
/* Write the table. Error processing not shown.  */
        int ftrans;
        long hdsize = 32;        /* Header size                */
        long cpsize = 4;         /* Code point size            */
        long rsv1 = 0, rsv2 = 0; /* Reserved area              */
ftrans = open("usr/lib/lpd/pio/transJP/newcodeset_IBM-932",
                O_CREAT | O_WRONLY, 0664);
write(ftrans, "PIOSMBCSXLATE000", 16);
write(ftrans, &hdsize, sizeof(long));
write(ftrans, &cpsize, sizeof(long));
write(ftrans, &rsv1, sizeof(long));
write(ftrans, &rsv2, sizeof(long));
write(ftrans, table, sizeof(table));

[ Previous | Next | Contents | Glossary | Home | Search ]