1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5 <TITLE>The Linux keyboard and console HOWTO: How to make other programs work with non-ASCII chars</TITLE>
6 <LINK HREF="kbd.FAQ-13.html" REL=next>
7 <LINK HREF="kbd.FAQ-11.html" REL=previous>
8 <LINK HREF="kbd.FAQ.html#toc12" REL=contents>
11 <A HREF="kbd.FAQ-13.html">Next</A>
12 <A HREF="kbd.FAQ-11.html">Previous</A>
13 <A HREF="kbd.FAQ.html#toc12">Contents</A>
15 <H2><A NAME="s12">12. How to make other programs work with non-ASCII chars</A></H2>
19 non-ASCII characters, using
21 <P>In the bad old days this used to be quite a hassle. Every separate
22 program had to be convinced individually to leave your bits alone.
23 Not that all is easy now, but recently a lot of gnu utilities have
24 learned to react to <CODE>LC_CTYPE=iso_8859_1</CODE> or <CODE>LC_CTYPE=iso-8859-1</CODE>.
25 Try this first, and if it doesn't help look at the hints below.
26 Note that in recent versions of libc the routine setlocale() only
27 works if you have installed the locale files (e.g. in
28 <CODE>/usr/lib/locale</CODE>).
29 <P>NOTE! The above was written years ago. Today locale stuff is a bit different.
30 Try the command <CODE>locale -a</CODE> to see which locales are available.
31 Then use one of these locale names instead of the <CODE>iso_8859-1</CODE>
32 mentioned above. For example, <CODE>LC_CTYPE=fr_FR.ISO-8859-1</CODE> or
33 <CODE>LC_CTYPE=fr_FR@euro</CODE>.
34 <P>NOTE! Some of the below may still be true. Most of it is outdated.
35 (Please report on what is incorrect today, so that it can be deleted.)
36 <P>First of all, the 8-th bit should survive the kernel input processing,
37 so make sure to have <CODE>stty cs8 -istrip -parenb</CODE> set.
38 <P>A. For <CODE>emacs</CODE> the details strongly depend on the version.
39 The information below is for version 19.34. Put lines
42 (set-input-mode nil nil 1)
43 (standard-display-european t)
48 into your <CODE>$HOME/.emacs</CODE>.
49 The first line (to be precise: the final 1)
50 tells <CODE>emacs</CODE> not to discard the 8-th bit from input characters.
51 The second line tells <CODE>emacs</CODE> not to display non-ASCII characters
53 The third line specifies the syntactic properties
54 and case conversion table for the Latin-1 character set
55 These last two lines are superfluous if you have something like
56 <CODE>LC_CTYPE=ISO-8859-1</CODE> in your environment.
57 (The variable may also be <CODE>LC_ALL</CODE> or even <CODE>LANG</CODE>.
58 The value may be anything with a substring `88591' or `8859-1'
60 <P>This is a good start.
61 On a terminal that cannot display non-ASCII ISO 8859-1 symbols,
65 (load-library "iso-ascii")
69 will cause accented characters to be displayed comme {,c}a.
70 If your keymap does not make it easy to produce non-ASCII characters,
74 (load-library "iso-transl")
78 will make the 2-character sequence Ctrl-X 8 a compose character,
79 so that the 4-character sequence Ctrl-X 8 , c produces c-cedilla.
88 will toggle ISO-8859-1 accent mode, in which the six
89 characters ', `, ", ^, ~, / are dead keys
90 modifying the following symbol.
91 Special combinations: ~c gives a c with cedilla,
92 ~d gives an Icelandic eth, ~t gives an Icelandic thorn,
93 "s gives German sharp s, /a gives a with ring,
94 /e gives an a-e ligature, ~< and ~> give guillemots,
95 ~! gives an inverted exclamation mark,
96 ~? gives an inverted question mark, and '' gives an acute accent.
97 This is the default mapping of accents.
98 The variable <CODE>iso-languages</CODE> is a list of pairs (language name,
99 accent mapping), and a non-default mapping can be selected using
102 (iso-accents-customize LANGUAGE)
106 Here LANGUAGE can be one of <CODE>"portuguese"</CODE>, <CODE>"irish"</CODE>,
107 <CODE>"french"</CODE>, <CODE>"latin-2"</CODE>, <CODE>"latin-1"</CODE>.
108 <P>Since the Linux default compose character is Ctrl-.
109 it might be convenient to use that everywhere. Try
112 (load-library "iso-insert.el")
113 (define-key global-map [?\C-.] 8859-1-map)
117 The latter line will not work under <CODE>xterm</CODE>, if you use <CODE>emacs -nw</CODE>,
118 but in that case you can put
121 XTerm*VT100.Translations: #override\n\
122 Ctrl <KeyPress> . : string("\0308")
126 in your <CODE>.Xresources</CODE>.)
127 <P>B. For <CODE>less</CODE>, put <CODE>LESSCHARSET=latin1</CODE> in the environment.
128 This is also what you need if you see <CODE>\255</CODE> or <CODE><AD></CODE>
129 in <CODE>man</CODE> output: some versions of <CODE>less</CODE> will render the soft hyphen
130 (octal 0255, hex 0xAD) this way when not given permission to output Latin-1.
131 <P>C. For <CODE>ls</CODE>, give the option <CODE>-N</CODE>. (Probably you want to make an alias.)
132 <P>D. For <CODE>bash</CODE> (version 1.13.*), put
141 into your <CODE>$HOME/.inputrc</CODE>.
142 <P>E. For <CODE>tcsh</CODE>, use
146 setenv LC_CTYPE iso_8859_1
150 If you have nls on your system, then the corresponding routines are used.
151 Otherwise <CODE>tcsh</CODE> will assume iso_8859_1, regardless of the values given to
152 LANG and LC_CTYPE. See the section NATIVE LANGUAGE SYSTEM in tcsh(1).
153 (The Danish HOWTO says: <CODE>setenv LC_CTYPE ISO-8859-1; stty pass8</CODE>)
154 <P>F. For <CODE>flex</CODE>, give the option <CODE>-8</CODE> if the parser it generates must be
155 able to handle 8-bit input. (Of course it must.)
156 <P>G. For <CODE>elm</CODE>, set <CODE>displaycharset</CODE> to <CODE>ISO-8859-1</CODE>.
157 (Danish HOWTO: <CODE>LANG=C</CODE> and <CODE>LC_CTYPE=ISO-8859-1</CODE>)
158 <P>H. For programs using curses (such as <CODE>lynx</CODE>) David Sibley reports:
159 The regular curses package uses the high-order bit for reverse video mode
160 (see flag _STANDOUT defined in <CODE>/usr/include/curses.h</CODE>). However,
161 <CODE>ncurses</CODE> seems to be 8-bit clean and does display iso-latin-8859-1
163 <P>I. For programs using <CODE>groff</CODE> (such as <CODE>man</CODE>), make sure to use
164 <CODE>-Tlatin1</CODE> instead of <CODE>-Tascii</CODE>. Old versions of the program <CODE>man</CODE>
165 also use <CODE>col</CODE>, and the next point also applies.
166 <P>K. For <CODE>rlogin</CODE>, use option <CODE>-8</CODE>.
167 <P>L. For <CODE>joe</CODE>,
168 <CODE>metalab.unc.edu:/pub/Linux/apps/editors/joe-1.0.8-linux.tar.gz</CODE>
169 is said to work after editing the configuration file. Someone else said:
170 <CODE>joe</CODE>: Put the <CODE>-asis</CODE> option in <CODE>/isr/lib/joerc</CODE> in the
172 <P>M. For LaTeX: <CODE>\documentstyle[isolatin]{article}</CODE>.
173 For LaTeX2e: <CODE>\documentclass{article}\usepackage{isolatin}</CODE>
174 where <CODE>isolatin.sty</CODE> is available from
175 <A HREF="ftp://ftp.vlsivie.tuwien.ac.at/pub/8bit">ftp.vlsivie.tuwien.ac.at/pub/8bit</A>.
176 <P>A nice discussion on the topic of ISO-8859-1 and how to manage 8-bit
177 characters is contained in the file <CODE>grasp.insa-lyon.fr:/pub/faq/fr/accents</CODE>
178 (in French). Another fine discussion (in English) can be found in
179 <A HREF="ftp://rtfm.mit.edu/pub/usenet-by-group/comp.answers/internationalization/iso-8859-1-charset">rtfm.mit.edu:pub/usenet-by-group/comp.answers/internationalization/iso-8859-1-charset</A>.
180 <P>If you need to fix a program that behaves badly with 8-bit characters,
181 one thing to keep in mind is that if you have a signed char type then
182 characters may be negative, and using them as an array index will fail.
183 Several programs can be fixed by judiciously adding (unsigned char) casts.
186 <A HREF="kbd.FAQ-13.html">Next</A>
187 <A HREF="kbd.FAQ-11.html">Previous</A>
188 <A HREF="kbd.FAQ.html#toc12">Contents</A>