https://invisible-island.net/luit/
luit - Locale and ISO 2022 support for Unicode terminals
luit [options ] [-- ] [program [args ] ]
Luit is a filter that can be run between an arbitrary application and a UTF-8 terminal emulator. It will convert application output from the locale's encoding into UTF-8, and convert terminal input from UTF-8 into the locale's encoding.Luit reads its input from the child process, i.e., an application running in the terminal.Luit writes its output to the terminal. The two (input and output) can have different encodings. An application may also request switching to a different output encoding using ISO 2022 and ISO 6429 escape sequences. Use of this feature is discouraged: multilingual applications should be modified to directly generate UTF-8 instead.Luit is usually invoked transparently by the terminal emulator. For information about runningluit from the command line, see EXAMPLES below.
-V Printluit's version and quit.-aliasfilename the locale alias file (default: ).-argv0name Set the child's name (as passed in argv[0]).-c Function as a simple converter from standard input to standard output.-encodingencoding Set upluit to useencoding rather than the current locale's encoding.-g0charset Set the output charset initially selected in G0. The default depends on the locale, but is usuallyASCII.-g1charset Set the output charset initially selected in G1. The default depends on the locale.-g2charset Set the output charset initially selected in G2. The default depends on the locale.-g3charset Set the output charset initially selected in G3. The default depends on the locale.-glgn Set the initial assignment of GL in the output. The argument should be one ofg0,g1,g2 org3. The default depends on the locale, but is usuallyg0.-grgk Set the initial assignment of GR in the output. The default depends on the locale, and is usuallyg2 except for EUC locales, where it isg1.-h Display a usage and options message on the standard output and quit.-ilogfilename Log intofilename all the bytes received from the child.-k7 Generate seven-bit characters for keyboard input.-kg0charset Set the input charset initially selected in G0. The default depends on the locale, but is usuallyASCII.-kg1charset Set the input charset initially selected in G1. The default depends on the locale.-kg2charset Set the input charset initially selected in G2. The default depends on the locale.-kg3charset Set the input charset initially selected in G3. The default depends on the locale.-kglgn Set the initial assignment of GL in the input. The argument should be one ofg0,g1,g2 org3. The default depends on the locale, but is usuallyg0.-kgrgk Set the initial assignment of GR in the input. The default depends on the locale, and is usuallyg2 except for EUC locales, where it isg1.-kls Generate locking shifts (SO/SI) for keyboard input.+kss Disable generation of single-shifts for keyboard input.+kssgr Use GL codes after a single shift for keyboard input. By default, GR codes are generated after a single shift when generating eight-bit keyboard input.-list List the supported charsets and encodings, then quit.Luit uses its internal tables for this, which are based on thefontenc library.-list-builtin List the built-in encodings used as a fallback when data fromiconv orfontenc is missing. This option relies onluit being configured to useiconv, since thefontenc library does not supply a list of built-in encodings.-list-fontenc List the encodings provided by ".enc" files originally distributed with thefontenc library.-list-iconv List the encodings and locales supported by theiconv library.Luit adapts its internal tables offontenc names toiconv encodings. To make scripting simpler,luit ignores spaces, underscores and ASCII minus-signs (dash) embedded in the names.Luit also ignores case when matching charset and encoding names. This option lists only the encodings which are associated with the locales supported on the current operating system. The portableiconv application provides a list of its supported encodings with the-l option. Other implementations may provide similar functionality. There is no portable library call by which an application can obtain the same information.-ologfilename Log intofilename all the bytes sent to the terminal emulator.+ols Disable interpretation of locking shifts in application output.+osl Disable interpretation of character set selection sequences in application output.+oss Disable interpretation of single shifts in application output.+ot Disable interpretation of all sequences and pass all sequences in application output to the terminal unchanged. This may lead to interesting results.-p In startup, establish a handshake between parent and child processes. This is needed for some older systems, e.g., to successfully copy the terminal settings to the pseudo-terminal.-preferlist Set the lookup-order preference for character set information. The parameter is a comma-separated list of keywords. The default order (listing all keywords) is fontenc,builtin,iconv,posix The default order usesfontenc first because this allowsluit to start more rapidly (about 0.1 seconds) than usingiconv for complex encodings such as eucJP. However, you may find that the iconv implementation is more accurate or complete. In that case, you can use the-show-iconv option to obtain a text file which can be used as an encoding with thefontenc configuration. This option relies onluit being configured to useiconv, since thefontenc library does not provide this choice.-show-builtinencoding Show a built-in encoding, e.g., from a ".enc" file using the ".enc" format. This option relies onluit being configured to useiconv, since thefontenc library does not supply a list of built-in encodings.-show-fontencencoding Show a given encoding, e.g., from a ".enc" file using the ".enc" format. Ifluit is configured to use thefontenc library, it obtains the information using that library. Otherwiseluit reads the file directly. Some offontenc's encodings are built into the library. Thefontenc library uses those in preference to an external file. Use the-show-builtin option to provide similar information whenluit is configured to useiconv.-show-iconvencoding Show a given encoding, using the ".enc" format. Ifluit is configured to useiconv, it obtains the information using that interface. Ificonv cannot supply the information,luit may use a built-in table.-t Initializeluit using the locale and command-line options, but do not open a pty connection. This option is used for testingluit's configuration. It will exit with success if no errors were detected. Repeat the-t option to cause warning messages to be treated as errors.-v Be verbose. Repeating the option, e.g., "-v-v" makes it more verbose.Luit does not usegetopt, so "-vv" does not work.-x Exit as soon as the child dies. This may causeluit to lose data at the end of the child's output.-- End of options.
Luit uses these environment variables: FONT_ENCODINGS_DIRECTORY overrides the location of the "encodings.dir" file, which lists encodings in external ".enc" files. LC_ALL LC_CTYPE LANG During initialization,luit callssetlocale to check if the user's locale is supported by the operating system. Ifsetlocale returns a failure,luit looks instead at these variables in succession to obtain any clues from the user's environment for locale preference. NCURSES_NO_UTF8_ACSLuit sets this to tell ncurses to not rely upon VT100 SI/SO controls for line-drawing. SHELL This is normally set by shells other than the Bourne shell, as a convention.Luit will use this value (rather than the user's entry in /etc/passwd) to decide which shell to execute. If SHELL is not set,luit executes /bin/sh.
Thefilemappinglocalestolocaleencodings.
None of this complexity should be necessary. Stateless UTF-8 throughout the system is the way to go. Charsets with a non-trivial intermediary byte are not yet supported. Selecting alternate sets of control characters is not supported and will never be.
On systems with SVR4 ("Unix-98") ptys (Linux version 2.2 and later, SVR4),luit should be run as the invoking user. On systems without SVR4 ("Unix-98") ptys (notably BSD variants), runningluit as an ordinary user will leave the tty world-writable; this is a security hole, andluit will generate a warning (but still accept to run). A possible solution is to makeluit suid root;luit should drop privileges sufficiently early to make this safe. However, the startup code has not been exhaustively audited, and the author takes no responsibility for any resulting security issues.Luit will refuse to run if it is installed setuid and cannot safely drop privileges.The most typical use ofluit is to adapt an instance ofXTerm to the locale's encoding. Current versions ofXTerm invokeluit automatically when it is needed. If you are using an older release ofXTerm, or a different terminal emulator, you may invokeluit manually: $ xterm -u8 -e luit If you are running in a UTF-8 locale but need to access a remote machine that doesn't support UTF-8,luit can adapt the remote output to your terminal: $ LC_ALL=fr_FR luit ssh legacy-machineLuit is also useful with applications that hard-wire an encoding that is different from the one normally used on the system or want to use legacy escape sequences for multilingual output. In particular, versions ofEmacs that do not speak UTF-8 well can useluit for multilingual output: $ luit -encoding 'ISO 8859-1' emacs -nw And then, inEmacs, M-x set-terminal-coding-system RET iso-2022-8bit-ss2 RET
Luit was written by Juliusz Chroboczek <jch@pps.jussieu.fr> for the XFree86 project. Thomas E. Dickey has maintainedluit for use byxterm since 2006.
These are portable:oxterm(1),oncurses(3X). These are Linux-specific:ounicode(7),outf-8(7),ocharsets(7). These are particularly useful:oCharacter Code Structure and Extension Techniques (ISO 2022,ECMA-35)oControl Functions for Coded Character Sets (ISO 6429,ECMA-48)ohttps://czyborra.com/charsets/ X Window SystemLUIT(1)