2    Using Asian Input Methods and Terminal Drivers

This chapter describes how to use the operating system in Asian environments and includes information on how to perform the following tasks:

This chapter describes the operating system commands and utilities you can use to configure the system for an Asian environment. If you are a system manager or administrator with superuser privileges, you can also use the menu-oriented Configure International Software utility found on the SysMan Menu under Software. See Section 1.2 for information on the configuration options available to you with this utility.

The operating system documentation set includes four manuals that offer technical reference and user information for the operating system in an Asian environment. The manuals have the following titles:

The Tru64 UNIX documentation is available on the World Wide Web at the following URL:


http://www.tru64unix.compaq.com/docs/

2.1    Determining Input Method

In a Motif environment, the operating system provides Asian language input methods that allow you to enter characters or phrases from your alphabetic keyboard, convert that keyboard entry into the appropriate Asian characters, and transmit those characters to an X client application. The Writing Software for the International Market manual describes how to write internationalized applications that take advantage of Asian input methods. Because use of a particular input method is language dependent, that information is covered in the technical references listed in the previous section and in the online help associated with each input method.

This section describes the input methods available on your system and how to invoke them.

Before you can use an Asian input method, you must establish an appropriate locale; set a preediting, or interactive, style; and start the input method server.

See Section 1.3 for information on establishing a locale.

A preediting, or interactive, style determines how you will interact with the input method to enter characters from the keyboard. That is, an Asian input method server often requires you to type multiple keystrokes to compose an Asian character. This process is called preediting. The X Input Method specification, which internationalized applications follow, defines the following preediting styles:

To set the preediting style, you can use dtterm with an -xrm option. You can also use the Session Manager Options Menu. However, the simplest method is to use the dtimsstart command as follows:

  1. From the command line, enter /usr/dt/bin/dtimsstart.

  2. Click on the appropriate radio button to choose a preediting style.

  3. Click on OK.

For some of the input styles selected in an application, the preediting and status windows are not redrawn correctly if the application window is hidden by other windows. To correct this problem, click on the application window to bring it to the foreground (in focus).

The operating system provides input servers for traditional and simplified Chinese (Hanyu and Hanzi respectively), Japanese, and Korean. Each input server provides you with one or more input methods appropriate for variations within each language. For example, the simplified Chinese Input Server provides input methods for these input styles: 5-Stroke, 5-Shape, Pin-Yin, Symbol, Telex code, Qu-Wei, and Intelligent ABC.

An input server runs as an independent process and communicates with an application to handle input operations. You can run the input server remotely or locally. After you start the input server and activate an input method, any internationalized Motif application that supports the selected input method can communicate with the input server.

Ordinarily, you must start the application after you start the input server. However, if the application contains an XmText or XmTextField widget with the Reconnectable resource set to True, the application can connect with the input server regardless of which one starts first.

You can start an individual input server from the command line or, for non-Japanese Asian languages, you can use the dxim Input Server. The dxim Input Server is a menu-oriented server that supports Korean, traditional Chinese, simplified Chinese, and Phrase input methods under a single protocol and allows you to switch from one input method engine to another from the same or different locales.

When a client application connects to dxim and you use the keyboard to enter characters, the dxim Input Server converts the character data and sends it to the application. The conversion is English to an Asian language variant using traditional Chinese, simplified Chinese, or Korean Input Method server engines (dxhanyuim, dxhanziim, and dxhangulim, respectively). dxim selects an input method based on the client's locale and the input method server engines (called classes) and methods that you have activated.

The dxim Input Server supports only Off-the-Spot and Root Window preediting styles. Also, the dxim Phrase input is different from the operating system Phrase Utility. While the dxim Phrase Input Server method allows you to store characters and phrases in a manner similar to the operating system Phrase Utility, dxim does not support the Phrase Utility phrase database.

The dxim Input Server provides the following functions:

The dxim Input Server can support multiple client applications running under different locales. When a client connects to dxim, the Input Server determines the client's locale and which input methods are active and usable by the client. It then uses the appropriate input method to service the clients' needs. Depending on locale, dxim does not restrict an application to a single input server or method. For example, an application under the ko_KR.eucKR locale is restricted to the Korean Input Server because it recognizes only Korean characters. However, an application running under zh_TW.dechanyu, can use simplified or traditional Chinese Input Server methods because simplified and traditional characters are compatible. For more information on dxim, see the dxim online help or dxim(1X).

In addition to dxim, you can also run each input method server individually. The following input method servers are available in the operating system, along with the input styles that each server supports:

Each of these servers has a corresponding reference page and each language has a corresponding technical reference.

The applications that you run may support more, fewer, or none of the preediting styles supported by a particular input server. The preedit option None applies when an input server rejects all input styles supported by the application.

In the CDE, the appropriate input server automatically starts when you select the session language. See Section 3.3 for restrictions that may require you to start an input server manually. For dxim, keep in mind that you must stop any active input server process before starting dxim.

For programming information on how to specify input styles and establish a priority order for them, see the Writing Software for the International Market manual.

2.2    Determining the Keyboard Input Mode Switch State

Asian writing systems include thousands of ideographs, but Asian keyboards include keys for only a small number of these characters. For Asian languages, you use an input method (incorporating control-key sequences, keypad-key sequences, or options in a workstation application) to convert one or more characters that you can input directly from the keyboard to other kinds of characters. Section 2.1 and the following reference pages discuss input methods for Asian languages: dxim(1X), dxhanziim(1X), dxhanyuim(1X), dxhangulim(1X), dxjim(1X), and Thai(5).

If your keyboard has a mode-switch LED (light-emitting diode), it is turned on or off, depending on whether you last toggled the special input mode on or off.

If you are using a workstation and your language is set to an Asian language, you can display the mode-switch LED on the screen by invoking the Keyboard Indicator application with the -map option, as follows:

% /usr/bin/X11/kb_indicator -map &

The -map option starts a Motif application that emulates a mode-switch LED. The application window contains one button, which is displayed as on or off, corresponding to the input mode state. If input mode switching is supported for your current language setting, you can click on this button to toggle in and out of input mode.

You can have only one Keyboard Indicator application running during your session. To stop the application, press Ctrl/c in the window from which you started the application or enter the following kill command (where process_id is the application's process ID):

% kill -INT process_id

If the Keyboard Indicator application is stopped by any other means, you must erase the server status for the application so that it can be restarted cleanly. To erase server status, enter the following command before restarting the application:

% /usr/bin/X11/kb_indicator -clear

If your language is set to Hebrew, the Keyboard Manager application (/usr/bin/X11/decwkm) provides the same function as the Keyboard Indicator application provides for Asian languages.

2.3    Using Terminal Interface Features for Asian Languages

The Asian terminal driver (atty) and the Thai terminal driver (ttty) support input and output of English and other language characters over asynchronous terminal lines. When one or both of these drivers are installed, you can set terminal line characteristics to be appropriate for the language you are using. The driver's local language capabilities are supported in the following terminal configurations:

See atty(7) and ttty(7) for more information about these terminal drivers.

The stty command can enable support for multibyte codesets and special character manipulation capabilities, such as the following:

This section provides general information about using the stty command to enable features added to the terminal subsystem for Asian languages.

The stty utility sets or reports on terminal input and output characteristics of the device that is the utility's standard input. Table 2-1 describes the stty options that set line discipline for Asian languages.

Table 2-1:  The stty Command Options for Controlling Terminal Line Discipline

stty Option Description
adec Sets the terminal line discipline to handle multibyte data and the processing environment appropriate for simplified Chinese (Hanzi), traditional Chinese (Hanyu), and Korean (Hangul) codesets. This option is supported for both the STREAMS and BSD terminal drivers.
jdec Sets the terminal line discipline to handle multibyte data and the processing environment appropriate for Japanese codesets. This option sets terminal code to dec and application code to eucJP. The jdec option is supported for both the STREAMS and BSD terminal drivers.
tdec Sets the terminal line discipline to handle Thai characters and the processing environment appropriate for the Thai codeset. This option is supported only for the BSD terminal driver.
dec Sets the terminal line discipline back to the default, or standard, tty line discipline and clears characteristics that preceding stty commands may have set for application and terminal code. This option is supported for both the STREAMS and BSD terminal drivers.

Note

Do not set the terminal line discipline to jdec or adec from a console set up for kernel debugging (running the KDEBUG driver). Doing so may cause the console to hang.

The stty command requires an appropriate locale setting to be in effect before you can change the terminal line discipline to support that locale. For example, to set your terminal line discipline to handle Korean, enter the following:

% setenv LANG ko_KR.deckorean
% stty adec

To set your terminal line discipline back to the tty default, enter the following:

% stty dec

Note

When your terminal line discipline is not set to the tty default and you want to switch to another nondefault option (to switch from jdec to adec, for example), first enter the stty dec command to clear any application or terminal characteristics that may not be appropriate for the new setting. The following example switches a terminal line discipline from its current setting of adec to jdec:

% stty dec
% stty jdec

The stty command entered with the -a option or -all argument displays the following settings for the current terminal line discipline:

% stty adec
% stty all
atty disc;speed 9600 baud; 24 rows; 80 columns
erase = ^?; werase = ^W; kill = ^U; intr = ^C; quit = ^\; susp = ^Z
dsusp = ^Y; eof = ^D; eol <undef>; eol2 <undef>; stop = ^S; start = ^Q
lnext = ^V; discard = ^O; reprint = ^R; status <undef>; time = 0
min = 1
-parenb -parodd cs8 -cstopb hupcl cread -clocal
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh -mdmbuf -nohang
-tostop echoctl -echoprt echoke -altwerase iexten -nokerninfo
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tabs -onoeot
-odl lru size=256
-sim key= class=
tcode=dec acode=deckanji

If you are superuser, you can use the wwconfig command or the Configure International Software utility from the SysMan Menu to perform the following tasks:

For more information, see wwconfig(8) or the Configure International Software online help.

2.3.1    Converting Between Application and Terminal Codesets

Many terminals support only one codeset, which is a problem when you work on one terminal and need to run applications in locales (particularly Asian locales) that are based on a variety of codesets. Therefore, the atty driver provides a mechanism for converting between the codeset that an application uses and the codeset that a terminal supports. You control codeset conversion by using options on the stty command line.

The adec, jdec, and dec options of the stty command set terminal code and application code appropriately for HP terminals and workstations. You need to explicitly use the tcode option, for example, if you are logging in from a Japanese terminal that does not support the same codeset as HP terminals and workstations.

Table 2-2 specifies stty options that explicitly set terminal and application code.

Table 2-2:  The stty Options to Explicitly Set Application and Terminal Code

stty Option Description
acode codeset Sets application code to codeset.
tcode codeset Sets terminal code to codeset.
code codeset Sets both terminal code and application code to codeset.
conv (-conv) Enables or disables codeset conversion between internal code and the terminal or application code. Codeset conversion must be enabled for Asian terminal features to work.

The following command lets you run an application that uses DEC Kanji on a terminal that supports only Shifted JIS (a codeset prevalent in the Japanese personal computer market):

% stty acode deckanji tcode SJIS

The technical reference manuals for the Asian language features, available from the Programming Bookshelf of the operating system documentation Web site, provide additional information about supported application codesets and terminal codesets ( http://www.tru64unix.compaq.com/docs/).

2.3.2    Command Line Editing That Supports Multibyte Characters

This section discusses how you enable and use command line editing when Asian language support is installed on your system.

When the terminal line discipline and terminal codeset characteristics are set appropriately for multibyte codesets, the atty driver handles command line editing appropriately for languages supported by those codesets. For example, when you enter the control sequence to delete a character (assuming you have defined the control sequence), the entire character is deleted, regardless of how many bytes it occupies. The character being erased can be either a single-byte character or a multibyte Asian character when both occur on the same command line.

Word deletion is also supported, even when words combine single-byte and multibyte characters. The atty driver accepts single-byte space characters, 2-byte space characters (if applicable to the terminal code setting), or tab characters as word delimiters.

The erase and werase options of the stty command line let you define the control sequence for character and word deletion. For example:

% stty erase [Ctrl/h]
% stty werase [Ctrl/j]

This example specifies that Ctrl/h deletes the character preceding the cursor and Ctrl/j deletes the word preceding the cursor.

History mode is a mode of command line editing that allows you to recall and optionally modify a command entered previously. The history mode implementation discussed here is one that is customized for Japanese, Chinese, and Korean input and supported only for the BSD terminal driver. Table 2-3 specifies the stty options that enable or disable history mode editing for these languages. See Table 2-6 for stty options that control history mode for the Thai language.

Table 2-3:  The stty Options Used with atty to Enable and Disable History Mode

stty Option Description
history key Sets the toggle key for the history mechanism and enables it.
-history Disables the history mechanism.

The atty driver can maintain a history of up to 32 commands, each with a maximum length of 127 characters. Table 2-4 describes the commands you can use to edit command lines after entering the history key.

Table 2-4:  Command Line Editing in History Mode

Command/Key Description
Ctrl/a Move to the beginning of the line.
Ctrl/d Delete the character under the cursor.
Ctrl/e Move to the end of the line.
Up-arrow Recall the previous command line in the history list.
Down-arrow Recall the next command in the history list.
Left-arrow Move the cursor left by one character.
Right-arrow Move the cursor right by one character.
erase_sequence Delete the character preceding the cursor.
werase_sequence Delete the word preceding the cursor.

In Table 2-4, the erase_sequence and werase_sequence command keys indicate the control sequences defined by the stty options -erase and -werase, respectively.

When editing a command line in history mode, you insert characters as follows:

  1. Press the arrow keys to move the cursor to the position immediately to the right of the point where you want to insert characters.

  2. Enter the characters you want to insert.

If you enter the control characters that represent "kill," "interrupt," or "suspend," the tty driver breaks out of history mode and cancels the command line being edited.

2.3.3    Kana-Kanji Conversion: Customization of Japanese Input Options

In the Japanese language, a particular language element, such as a vowel, can be represented by more than one character. These characters can have both phonetic and ideographic variants; furthermore, the phonetic character variants can print in either 2-column or single-column width. The different classes of characters, listed in the following table, require different input schemes:

Character Class Description
Kanji Ideographic
Hiragana Phonetic
Katakana Phonetic Katakana characters exist in full width (2-column) and half width (single-column) formats. The single-column format of Katakana is referred to as Hankaku.

During a single session, a Japanese user can work with Kanji, Hiragana, and Katakana characters in various combinations. The user therefore must be able to customize terminal input mode to suit the character being entered. When the input device is a JIS terminal rather than a workstation, the user must adjust line discipline and terminal code settings in the software to match hardware capabilities (for example, whether the terminal uses 7-bit or 8-bit encoding).

The tty driver supports a mechanism known as Kana-Kanji conversion. This term refers to the conversion between phonetic and ideographic characters and the support for keyboard entry sequences that make Japanese character selection more efficient for the user. You use the stty command to enable or disable the Kana-Kanji conversion method and other aspects of Japanese input support. The stty options that support Japanese input are described in Table 2-5 and, unless noted otherwise, are used in conjunction with the jdec option. For example, the following command sets the terminal line discipline to support Japanese character encoding and also enables Kana-Kanji conversion:

% stty jdec ikk

Table 2-5:  The stty Options to Enable and Customize Japanese Input

stty Option Description
clause mode

Sets the character attribute for marking a clause that results from Kana-Kanji conversion.

The mode argument can be bold, underline, reverse, or none.

esc.alw

Changes the terminal state to "shift out" whenever a newline character is output.

This option applies only when the tcode (terminal code) stty option is set to jis7 or jis8.

-esc.alw

Does not change the current terminal state when a newline character is output.

This option applies only when the tcode (terminal code) option is set to jis7 or jis8.

henkan mode

Sets the character attribute for marking a Henkan, or conversion, region that results from Kana-Kanji conversion.

The mode argument can be bold, underline, reverse, or none.

ikk

Enables the Japanese input method and spawns the Kana-Kanji conversion daemon, kkcd, if it does not already exist. With the BSD terminal driver in cbreak mode, you must use the jx option before using the ikk option to enable the input method. With the STREAMS terminal driver, you must use the jinkey option before using the ikk option.

By default, keymap information is taken from (in highest to lowest priority order):

  1. The file specified for the kkseq option of the stty command

  2. The file defined for the JSYKKSEQ environment variable

  3. The $HOME/.jsykkseq file

System default keymap files for the Japanese input method reside in the /usr/i18n/skel/ja_JP directory.

Dictionaries used with the Japanese input method are taken from the following list (in highest to lowest priority order):

  1. The files defined for the JSYTANGO, JSYKOJIN, and JSYLEARN environment variables

  2. The /usr/i18n/jsy/jsytango.dic, $HOME/jsykojin.dic, and $HOME/jsylearn.dic dictionary files

-ikk Disables the Japanese input method and kills the kkcd daemon.
jinkey sequence Defines the escape sequence to activate the extended Japanese input method used with the STREAMS terminal driver. The parameter for this option can be more than one character.
imode mode

Sets the mode for handling 8-bit code or Hankaku (single-column) Kana code when the terminal line discipline is set to dec. The mode argument can be one of the following keywords:

  • kanji, where the 8-bit code is treated as encoding for Kanji

  • hiragana, where the 8-bit code is converted to 2-column Hiragana format

  • katakana, where the 8-bit code is converted to 2-column Katakana format

  • hankaku, where the 8-bit code is handled in Hankaku (1-column) Katakana format

jx character Sets the toggle character for entering the extended, or cbreak, Kana-Kanji conversion mode used with the BSD terminal driver. Enter cbreak mode when working in utilities, such as dbx, that do not support the full range of Japanese input options.
-jx Undefines the toggle character for entering the extended Kana-Kanji conversion mode.
kin esc_sequence Sets the JIS Kanji "shift in" escape sequence for the JIS terminal.
kkmap Displays the current keymap for Kana-Kanji conversion. The display is a traversal tree with a maximum of 15 characters for each key sequence.
kkseq file Sets the Kana-Kanji conversion keymap file for the terminal (see also the table entry for the ikk option).
knj.bsl Uses only one backspace to erase one Kanji character.
-knj.bsl Uses two backspaces to erase one Kanji character.
knj.sp Uses one 2-byte (zenkaku) space to blank out one Kanji character.
-knj.sp Uses two ASCII spaces to blank out one Kanji character.
kout esc_sequence Sets the JIS Kanji "shift out" escape sequence for the JIS terminal.

All ASCII characters are represented by single-byte, 7-bit values in DEC Kanji. That is, the most significant bit (MSB) is always set to Off in the byte that represents an ASCII character. For Unicode conversion on Tru64 UNIX, the Japanese_UCS converters (deckanji, sdeckanji, SJIS, and eucJP) consider the lower 7-bit values to be ASCII.

2.3.4    Thai Terminal Support

Thai terminals are supported by the ttty terminal driver, which uses the BSD protocol. When using a Thai terminal, you must set the terminal line discipline to tdec, for example:

% stty tdec
 
 

Table 2-6 describes additional settings that the stty command supports for Thai terminals.

Table 2-6:  The stty Options for Thai Terminals

stty Option Description
isc mode Sets the mode for the Wototo Input Sequence Check (ISC). Valid mode values are 0 (pass through), 1 (basic), and 3 (strict). This option is not used in Thai history mode.
reorder (-reorder) Enables or disables input reordering. This option is not used in Thai history mode.
thistory key (-thistory) Enables or disables the Thai history mechanism. The specified key is the one used to toggle in and out of Thai history mode. Lines fewer than three characters in length are not recorded in the history list. The command line editing options you can use when Thai history mode is enabled are the same as those described in Table 2-4.

See ttty(7) for more information about these options.