---
name: "hztty"
section: "1"
platform: "linux"
package: "hztty"
version: "2.0-6.1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/hztty"
---

# hztty(1)

make a tty session understand different encodings

## NAME

hztty - make a tty session understand different encodings

## SYNOPSIS

**hztty** \[ **-h** \] \[ **-I** *input-stream* \] \[ **-O** *output-stream* \] \[command line\]

## DESCRIPTION

**hztty** translates Chinese codes on your terminal from some *foreign* encoding or representation standard to the *native* encoding understandable by your terminal. A *native* encoding is the standard used by your terminal session, for example \`\`GB'' on \`\`cxterm'', \`\`Big5'' on \`\`cxterm -BIG5'' or ET Dos. A *foreign* encoding is the one used by application running on the terminal, for example, the \`\`zW/HZ'' representation, the standard \`\`Unicode'', the ASCII-compatible \`\`UTF8'', the mail-safe \`\`UTF7'', etc. **hztty** also translates Chinese codes you input on your terminal from the native encoding to the foreign encoding used by the application.

**hztty** was initially designed to read/post articles in the newsgroup \`\`alt.chinese.text'', in which the \`\`zW/HZ'' scheme is used to represent Chinese characters. Now it can do much more than that.

**hztty** ends when the forked shell exits.

## IO STREAMS

The Chinese code conversion in hztty is organized using the *stream* mechanism. A stream consists of one or more conversion modules. Each of these modules implements a different kind of code conversion. In a stream the conversion modules form a pipeline that  feeds one module's output to the next module's input. There is an input stream (from terminal input to the application) and an output stream (from the application to the terminal screen) in hztty. This version of hztty implements the following conversion modules.

- **hz2gb**

  It converts zW/HZ to GB, usually used in output stream.

- **gb2hz**

  It converts GB to zW/HZ, usually used in input stream. Note that you have to type in the escape sequences yourself and make the text conforms to HZ specification. Hztty enforces no encoding policy.

- **gb2big**

  It converts GB to Big5.

- **big2gb**

  It converts Big5 to GB.

- **uni-utf**

  It converts 16bit Unicode to 8-bit UTF format.

- **utf-uni**

  It converts 8-bit UTF format to 16bit Unicode.

- **uni-utf7**

  It converts 16bit Unicode to 7-bit mail-safe UTF format (RFC1642).

- **utf7-uni**

  It converts the 7-bit mail-safe UTF format to 16bit Unicode.

- **gb2uni**

  It converts GB to 16bit Unicode.

- **uni2gb**

  It converts 16bit Unicode to GB.

- **big2uni**

  It converts Big5 to 16bit Unicode.

- **uni2big**

  It converts 16bit Unicode to Big5.

- **toascii**

  **toupper** **tolower** They converts ASCII as those of [ctype(3)](/ctype/3.md).

- **dummy**

  It does no conversion, bindly copying from the previous module to the next module.

- **log(*filename*)**

  It does no conversion but saves a copy of every characters that passes through this module in a log file named *filename*. Be aware that the log file grows very fast since everything you type and all program output are saved.

## OPTIONS

- **-h**

  prints the help message and lists all the module implemented.

- **-I**

  specifies the input stream. If there are more than one modules in the stream, the module names are separated by \`:'. The default input stream is \`\`gb2hz''.

- **-O**

  specifies the output stream. If there are more than one modules in the stream, the module names are seperated by \`:'. The default output stream is \`\`hz2gb''.

If *command line* is not given, the user selected shell (from the environment variable SHELL) is invoked in the hztty session. Otherwise, the *command line* is invoked instead of the shell.

## EXAMPLES

Examples of conversion module combination in IO streams:

- **hztty**

  It implies the default input/output streams of **-O hz2gb -I gb2hz**. It is useful in reading and writing HZ style Chinese codes (as in the newsgroup \`\`alt.chinese.text'').

- **hztty -O hz2gb:gb2big -I big2gb:gb2hz**

  converts between HZ and Big5. In the output stream, HZ output are converted to GB first, then to Big5. In the input stream, Big5 input are converted to GB first, then to HZ. Useful in reading \`\`alt.chinese.text'' in a Big5 cxterm or other terminal emulator (e.g., kermit over IBM-PC running ET DOS).

- **hztty -O utf-uni:uni2gb -I gb2uni:uni-utf**

  converts UTF output into GB in the output stream and GB into UTF in the input stream.

## SEE ALSO

HZ - A Data Format for Exchanging Files of\
 Arbitrarily Mixed Chinese and ASCII characters

More on Unicode in ftp://unicode.org/pub/

## AUTHOR

Yongguang Zhang *(ygz@cs.purdue.edu)*

Copyright @ 1992, 1995 by Yongguang Zhang\
 Permission to use, copy, modify, and redistribute is hereby granted. The author disclaims all warranties with regarding to this software.

## CONTRIBUTORS AND ACKNOWLEDGEMENTS

Norm Matloff, University of California at Davis, *(matloff@cs.ucdavis.edu),* contributes his code for reading zW/HZ in a Big5 cxterm on the fly.

The Big5/GB conversion tables are generated from HC 1.2u, by Feng Feng Lee of Stanford University and Ricky Yeung of Washington University (now with Sun Microsystems).

The Unicode conversion tables are generated from Ross Paterson's utf7 package. *(\<rap@doc.ic.ac.uk\>)*

Shangjie Jin of Edinburgh University, UK, *(sjin@castle.edinburgh.ac.uk),* ported hztty to sequent boxes.

## BUGS

Cannot dynamically add (delete) a conversion module to (from) the streams.
