


This is a convenient little hack based on GNU iconv. Unlike that utility, which converts files, TTYConv converts interactive sessions, performing two-way conversion and taking care of other issues with interactive sessions.
I wrote TTYConv when I converted my entire system to UTF-8, only to realise that some of my (favourite) software, online services et cetera could not handle Unicode at all. Rather than fall back to ad hoc solutions to support natively four or five different encodings (two of which would be for Greek support alone), I'd keep UTF-8 and use a quick hack to translate from it to other encodings. Now I can do things like:
ttyconv --local=UTF-8 --remote=CP737 ssh -C sshbbs@bbs.acrogate.organd see the full range of BBSing characters in the aging IBM 'extended ASCII' character sets, converted to the more modern UTF-8. Use a nice Unicode font (I favour Andale Mono and Lucida Console), and you're set.
TTYConv is available as source, Debian and RPM packages. It's provided under the terms of the GNU General Public License, version 2.
|
ttyconv − Convert a TTY from one encoding to another |
|
ttyconv [-l
encoding|--local=ENCODING] [-r
encoding|--remote=ENCODING]
[SHELL-COMMAND] |
|
ttyconv converts a TTY session from one encoding to another. It uses the GNU C Library’s iconv(3) facility. This tool is useful when, for instance, you have a UTF-8 based system with national language and keyboard support and you still want to connect to systems that are unaware of this, or use a different (or bizarre) encoding. ttyconv is intended as a means of easing the transition from ‘legacy’ (sic) applications to ones that are fully UTF-8 aware without limiting their output to the US-ASCII encoding. ttyconv works by allocating a pseudo-tty, executing the specified command on the pty slave (the ‘remote’), and then translates: |
|
• |
the command’s output from the ‘remote encoding’ to the ‘local encoding’ and prints it to standard output. |
||
|
• |
the user’s input from the ‘local encoding’ to the ‘remote encoding’ and writes it to the pty’s standard input. |
|
SHELL-COMMAND is an ordinary shell command. The shell command (including any arguments) must appear at the end of the ttyconvq command line. If omitted, the value of the user’s SHELL environment variable is used to spawn a shell. As a last resort, /bin/sh is spawned. |
|
An exit status of zero indicates successful termination of the translated session. A non-zero exit status denotes abnormal termination due to an error that occurred while the terminal translation was being set up. |
|
ttyconv accepts the following arguments: |
|
-l, --local=LOCAL-ENCODING |
|
Set the local encoding to LOCAL-ENCODING. The encoding must be given in a format understood by the iconv(1) utility. Use iconv -l for the full list of encodings. This argument is mandatory. |
|
-r, --remote=REMOTE-ENCODING |
|
Set the remote encoding to LOCAL-ENCODING. The encoding must be given in a format understood by the iconv(1) utility. Use iconv -l for the full list of encodings. This argument is mandatory. |
|
-?, --help |
|
List all available options and their meanings. --usage Display brief usage information. |
|
-V, --version |
|
Show the program’s version, credits and licensing. |
|
This is an early version. Bugs are sure to be lurking within. |
|
Both translations are handled by calls to libiconv, and thus both forward and inverse conversions must be supported. This is not a problem if at one (or both) of the two encodings are flavours of Unicode (such as UTF-8). Other combinations of encodings may be a different story. Please refer to the iconv(1) man page for more details. |
|
Written by Alexios Chouchoulas. |
|
Report bugs to Alexios Chouchoulas <alexios@vennea.demon.co.uk>. |
|
Copyright © 2003 Alexios Chouchoulas
<alexios@vennea.demon.co.uk>. |
|
iconv(1), unicode(7), utf-8(7). |