2    Basic Setup of Japanese Environment

This chapter describes how to perform the following tasks to establish a basic Japanese environment on a Tru64 UNIX system.

2.1    Installing the Japanese Environment

To use the Japanese features that Tru64 UNIX offers, you must install the Worldwide Language Support subsets and Japanese subsets as well as the Tru64 UNIX base software subsets.

Figure 2-1:  Software Subsets Required to Use the Japanese Environment

The subsets in Figure 2-1 are needed to use the Japanese features and are automatically installed when you select Japanese in the installation procedure. For the detailed steps on the installation procedure, refer to the Installation Guide and Installation Guide — Advanced Topics.

To use any of the following Japanese features, you must install the associated software kit after installing the Tru64 UNIX Japanese environment:

2.2    Setting Up the Internationalization Environment

To use the Tru64 UNIX Japanese features, first set the following environment variables for the internationalization environment:

Tru64 UNIX provides the following script files to help you properly set the environment variables:

The scripts are template files. The system manager can modify either the /etc/i18n_profile or the /etc/i18n_login file, as appropriate.

Note

Do not modify the /etc/i18n_path file because it depends on the system directory structure.

If you use the /usr/sbin/i18nsetup command, the contents of the skeleton file are added to the end of each of the user's startup scripts ($HOME/.profile and $HOME/.cshrc). Use an ASCII editor to reposition these additions within the file.

If you are logged in as superuser (root), you can use the /usr/sbin/i18nsetup command to modify the startup script of any user. Consider the following example that modifies the startup files of users kanai and shimada.

# /usr/sbin/i18nsetup kanai shimada

If the startup files are properly modified, the commands and utilities for the Tru64 UNIX internationalization environment will be available when you log in to the system, or the settings will be reflected in the current shell environment using eval (for sh) or source (for csh).

Note

The descriptions of Japanese environment settings and operations in the remainder of this chapter assume that the environment variable settings for I18NPATH and PATH described in this section have been made. If the Japanese environment is not set up properly, examine the values of these environment variables.

2.3    Setting up the CDE Language

To set the language for each user in the CDE, select the appropriate locale from the Language submenu of the login dialog Options when logging in to the system. To set the system language to Japanese, select one of the Japanese locales (listed in Table 2-1) from the Language submenu.

Table 2-1:  Japanese Locales That Can Be Selected for the CDE Language Setting Option

Language Locale
Japanese ja_JP
Japanese (DEC Kanji) ja_JP.deckanji
Japanese (EUC) ja_JP.eucJP
Japanese (Super DEC Kanji) ja_JP.sdeckanji
Japanese (Unicode) ja_JP.UTF-8
Japanese (Shift JIS) ja_JP.SJIS

The value of the LANG environment variable for CDE sessions is automatically set using the language you select during login. Thus, you do not need to set the LANG environment variable in a startup script (such as .login).

Note

If you use this method to select a language for a CDE session, you must not define the LANG environment variable in the startup script. If there is a mismatch between the language you selected during login and the value of LANG in the startup script, the session might be unable to start properly.

2.3.1    Setting the CDE Default Language

If you select only Japanese when you install the Worldwide Language Support software, the default language for the window environment is automatically set to Japanese EUC (ja_JP.eucJP).

You can use the following procedure to change the default language for the Japanese window environment. This procedure is useful if you want to set a Japanese locale other than EUC for the default language for the window environment or if you selected more than one language when installing the Worldwide Language Support software.

  1. If an /etc/dt/config/Xconfig file exists, delete it.

  2. Create a new /etc/dt/config/Xconfig file using the following commands:

    # cd /etc/dt/config
    # ln -s Xconfig.locale-name Xconfig
    

    For example, to set the default language to Japanese EUC, use the following command.

    # ln -s Xconfig.ja_JP.euc.JP Xconfig
    

This setting is enabled for both the login screen and default session languages.

2.4    Setting Up the Japanese Locale

To associate the Tru64 UNIX internationalized commands and libraries with a particular Japanese environment, specify the locale that represents the desired combination of language, territory, and codeset.

To specify the locale name representing the locale, use the following format:

Language_Territory.Codeset

For Language, Territory, and Codeset, specify the respective language, territory, and character codeset names defined in the system.

Tru64 UNIX provides the Japanese locales listed in Table 2-2. All of these locales specify the Japanese language currently used in Japan; they differ with respect to the character codeset name used.

Table 2-2:  Japanese Locale Names Available for Tru64 UNIX

Locale Name Character Codeset Name Used
ja_JP.deckanji DEC Kanji
ja_JP.sdeckanji Super DEC Kanji
ja_JP.eucJP Japanese EUC
ja_JP.SJIS Shift JIS
ja_JP Japanese EUC
ja_JP.UTF-8 UTF-8

At installation, Tru64 UNIX stores the Japanese locale databases in the paths listed in Table 2-3.

Table 2-3:  Locale Databases

Locale Name Locale Databases
ja_JP.deckanji /usr/lib/nls/loc/ja_JP.deckanji
ja_JP.sdeckanji /usr/lib/nls/loc/ja_JP.sdeckanji
ja_JP.eucJP /usr/lib/nls/loc/ja_JP.eucJP
ja_JP.SJIS /usr/lib/nls/loc/ja_JP.SJIS
ja_JP.UTF-8 /usr/lib/nls/loc/ja_JP.UTF-8

To specify a Japanese locale, enter the appropriate locale name listed in Table 2-2 as the value for the LANG environment variable. The commands and utilities of the Tru64 UNIX internationalization environment will be associated with the locale name value set for the LANG environment variable.

In Tru64 UNIX, there are six categories of internationalized commands and libraries that differ from one locale to another. Table 2-4 describes the categories and the settings defined for each. The category names correspond with environment value names. You can independently specify a locale name suitable for each of these environment variables. You can also set up the locales with a variety of environment variable definitions, depending on the processing you want to accomplish.

Table 2-4:  Available Category Names

Category Name (Environment Variable Name) Settings
LC_COLLATE Collating sequence
LC_CTYPE Character class, character attribute (uppercase, lowercase, etc.)
LC_MESSAGES Message display format
LC_MONETARY Monetary format
LC_NUMERIC Numeric data format
LC_TIME Date/time format

To assign the same locale name to all these categories, use the LC_ALL environment variable.

The system applies the following priority in determining which environment variables control the locale settings:

  1. LC_ALL environment variable (when a valid locale name has been specified)

  2. LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME environment variables (when a valid locale name has been specified)

  3. LANG environment variable (when a valid locale name has been specified)

If you specified no locale name or an invalid locale name as an environment variable value, Tru64 UNIX assumes that the C locale has been specified. The C locale is the most basic environment and can process only ASCII characters. With the C locale, Japanese characters cannot be processed.

To view the settings of the current locale, use the locale command:

% locale

For more information on the locale command, see locale(1).

2.5    Setting Up the Japanese Terminal

To display Japanese characters on the terminal or input them through the keyboard, use the following command to set the terminal driver to the line discipline for Japanese characters:

% stty jdec

Immediately after execution of this command, the terminal driver is set as follows:

Item Appropriate stty Option Settings
Terminal I/O Code tcode dec DEC Kanji code
Application code acode codeset-name Japanese codeset being set for the locale (eucJP if no locale has been set)
Japanese Input Mode imode hiragana Input an 8-bit code as a 2-byte Hiragana code
Kanji Conversion -ikk Configuration Off

If your environment does not match the above settings, use the stty command to establish the appropriate setting. The following sections detail how to use the stty command to set handling of terminal and application codes and to set 8-bit data for your environment.

2.5.1    Setting the Terminal and Application Codes

You can independently set Kanji codes for each of the terminal and application codes. Various combinations are available.

The application program uses the terminal driver atty [Footnote 1] to communicate with the Tru64 UNIX terminal. The terminal driver atty is incorporated in the kernel (see Figure 2-2).

Figure 2-2:  Terminal Driver (Asian tty)

Tru64 UNIX allows you to select the respective character codes interchanged between the terminal, terminal driver, and application. Throughout this document, the character codes that the terminal uses for communication with the host are called terminal codes and the character codes that the application processes are called application codes.

2.5.1.1    Setting the Terminal Codeset

To set a character codeset other than DEC Kanji for the terminal codes, use the stty command with the -tcode option:

% stty tcode codeset-name

Table 2-5 lists the codeset names that you can set.

Table 2-5:  Possible Codeset Names for the Terminal Codesets

Codeset Name Associated Mnemonic
DEC Kanji dec
Shift JIS SJIS
Japanese EUC eucJP
7-bit JIS jis7
8-bit JIS jis8
UTF-8 UTF-8

2.5.1.2    Setting the Application Codes

To set the application codeset, use the stty command with the -acode option:

% stty acode codeset-name

Table 2-6 lists the codeset names that you can set.

Table 2-6:  Possible Codeset Names for the Application Codesets

Codeset Name Associated Mnemonic
DEC Kanji deckanji
Super DEC Kanji sdeckanji
Shift JIS SJIS
Japanese EUC eucJP
UTF-8 UTF-8

2.5.2    Handling of 8-Bit Data

The Tru64 UNIX system interprets 8-bit data (that is, data with the eighth bit on) that was input through the terminal in one of two ways:

  1. The data is interpreted as a 1-byte Kana character, and:

  2. The data is interpreted as part of a Kanji code of two or more bytes.

You can use the stty command with the -imode option to specify one of the following:

2.5.3    Checking the Current Terminal Settings

To view the current terminal settings, execute the stty command without flags or options:

% stty
atty disc;speed 9600 baud; -parity hupcl
erase = ^?
brkint -inpck -istrip icrnl -ixany onlcr
echo echoe echok
imode=hiragana
tcode=dec acode=deckanji
% 

The settings displayed correspond to the stty options. The options prefixed by a hyphen (-) are currently disabled; the others are currently enabled. See stty(1) for a full description of options.

2.6    File Code Conversion

The Tru64 UNIX iconv command converts file codes. The command uses the following format:

iconv -f input-code -t output-code file-name ...

The iconv command converts the input codeset to the output codeset and writes the resulting data to standard output or to the specified filename(s). You can specify any codeset name in Table 2-7.

Table 2-7:  Possible Codeset Names for use with iconv

Codeset Name Associated Mnemonic
DEC Kanji deckanji
Super DEC Kanji sdeckanji
Japanese EUC eucJP
Shift JIS SJIS
7-bit JIS JIS7
7-bit JIS [Footnote 2] jiskanji7
ISO-2022-JP Japanese Mail Code ISO-2022-JP
ISO-2022-JP Extended Japanese Mail Code ISO-2022-JPext
UCS-4 UCS-4
UCS-2 UCS-2
UTF-8 UTF-8

For example, the following command converts the foobar.txt Shift JIS coded text file into the foobar.sdc Super DEC Kanji text file:

% iconv -f SJIS -t sdeckanji foobar.txt >foobar.sdec

The user-defined character areas vary from codeset to codeset. When you use iconv for code conversion, make sure that the code values assigned to the character codes of the user-defined characters are also converted. For information on the user-defined character areas of the respective codesets and the character code correspondence between the codesets, see udc(5).

In addition to the codesets listed in Table 2-7, Tru64 UNIX supports file code conversion into codesets used with machines other than those manufactured by HP. Table 2-8 lists these codesets.

Table 2-8:  Possible Codeset Names for use with iconv (for Machines Not Manufactured by HP)

Codeset Name Associated Mnemonic
IBM Kanji System Character ibmkanji
Fujitsu JEF Code JEF
Hitachi KEIS KEIS

For details on the various codesets, see iconv_ibmkanji(5), iconv_JEF(5), and iconv_KEIS(5).

2.7    Message Catalogs

Programs output various messages during execution. When software contains message character strings embedded in the program, the contents of the output cannot vary according to the operating environment.

Instead of embedding message character strings in the program during execution, internationalized Tru64 UNIX commands and libraries reference a file containing logged message characters and output its contents in message form. A message catalog is the mechanism that references a file during execution and outputs the appropriate message.

Note

The contents of files containing messages have been compiled by the gencat command in binary form. Thus, they cannot be displayed using the cat command. To view the file contents, use the dspcat command.

During installation, Tru64 UNIX stores the Japanese locale message catalogs in directories. Table 2-9 describes the directory path associated with each of the Kanji codes specified with a locale name [Footnote 3] .

Table 2-9:  Directories Where Japanese Message Catalogs Exist

Kanji Code Directory of Japanese Message Catalog
Japanese EUC /usr/lib/nls/msg/ja_JP
DEC Kanji /usr/lib/nls/msg/ja_JP.deckanji
Super DEC Kanji /usr/lib/nls/msg/ja_JP.sdeckanji
Japanese EUC /usr/lib/nls/msg/ja_JP.eucJP
Shift JIS /usr/lib/nls/msg/ja_JP.SJIS
UTF-8 /usr/lib/nls/msg/ja_JP.UTF-8

2.8    Setting Up the Japanese Reference Pages

Tru64 UNIX provides Japanese reference pages that describe the commands and libraries available in the Japanese environment. Reference pages are documents you can view online using the man command. For example:

% man n title

The document associated with title is output to the terminal screen. The value n is the section number of the reference page. The reference pages are classified into the sections listed in Table 2-10.

Table 2-10:  Reference Page Section Numbers

Classification of Contents Associated Section Number
Commands 1
System Calls 2
Library Routines 3
File Formats 4
nroff macros, etc. 5
Special Files 7
System Management Commands 8

If the LANG environment variable is set for use in the Japanese environment, the man command searches for the directory that contains the simplified online operation file of the Japanese reference page (/usr/share/ja_JP.deckanji/man if LANG is ja_JP.deckanji) and displays the Japanese reference page.

If the LANG environment variable is set to ja_JP.SJIS, the man command searches for the /usr/share/ja_JP.eucJP/man directory and the codeset converter converts the format into SJIS.

When you need to view an English reference page, use the man command with the -M option as follows:

% man -M /usr/share/man title

For details about the man command, see man(1).