7a4c38fc0e19fd2e685790cc53cb2d083596e2ee
[platform/upstream/kbd.git] / doc / kbd.FAQ-12.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
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>
9 </HEAD>
10 <BODY>
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>
14 <HR>
15 <H2><A NAME="s12">12. How to make other programs work with non-ASCII chars</A></H2>
16
17 <P>
18 <!--
19 non-ASCII characters, using
20 -->
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>First of all, the 8-th bit should survive the kernel input processing,
30 so make sure to have <CODE>stty cs8 -istrip -parenb</CODE> set.
31 <P>A. For <CODE>emacs</CODE> the details strongly depend on the version.
32 The information below is for version 19.34. Put lines
33 <BLOCKQUOTE><CODE>
34 <PRE>
35         (set-input-mode nil nil 1)
36         (standard-display-european t)
37         (require 'iso-syntax)
38 </PRE>
39 </CODE></BLOCKQUOTE>
40
41 into your <CODE>$HOME/.emacs</CODE>.
42 The first line (to be precise: the final 1)
43 tells <CODE>emacs</CODE> not to discard the 8-th bit from input characters.
44 The second line tells <CODE>emacs</CODE> not to display non-ASCII characters
45 as octal escapes.
46 The third line specifies the syntactic properties
47 and case conversion table for the Latin-1 character set
48 These last two lines are superfluous if you have something like
49 <CODE>LC_CTYPE=ISO-8859-1</CODE> in your environment.
50 (The variable may also be <CODE>LC_ALL</CODE> or even <CODE>LANG</CODE>.
51 The value may be anything with a substring `88591' or `8859-1'
52 or `8859_1'.)
53 <P>This is a good start.
54 On a terminal that cannot display non-ASCII ISO 8859-1 symbols,
55 the command
56 <BLOCKQUOTE><CODE>
57 <PRE>
58         (load-library "iso-ascii")
59 </PRE>
60 </CODE></BLOCKQUOTE>
61
62 will cause accented characters to be displayed comme {,c}a.
63 If your keymap does not make it easy to produce non-ASCII characters, 
64 then
65 <BLOCKQUOTE><CODE>
66 <PRE>
67         (load-library "iso-transl")
68 </PRE>
69 </CODE></BLOCKQUOTE>
70
71 will make the 2-character sequence Ctrl-X 8 a compose character,
72 so that the 4-character sequence Ctrl-X 8 , c produces c-cedilla.
73 Very inconvenient.
74 <P>The command
75 <BLOCKQUOTE><CODE>
76 <PRE>
77         (iso-accents-mode)
78 </PRE>
79 </CODE></BLOCKQUOTE>
80
81 will toggle ISO-8859-1 accent mode, in which the six
82 characters ', `, ", ^, ~, / are dead keys
83 modifying the following symbol.
84 Special combinations: ~c gives a c with cedilla,
85 ~d gives an Icelandic eth, ~t gives an Icelandic thorn,
86 "s gives German sharp s, /a gives a with ring,
87 /e gives an a-e ligature, ~&lt; and ~&gt; give guillemots,
88 ~! gives an inverted exclamation mark,
89 ~? gives an inverted question mark, and '' gives an acute accent.
90 This is the default mapping of accents.
91 The variable <CODE>iso-languages</CODE> is a list of pairs (language name,
92 accent mapping), and a non-default mapping can be selected using
93 <BLOCKQUOTE><CODE>
94 <PRE>
95         (iso-accents-customize LANGUAGE)
96 </PRE>
97 </CODE></BLOCKQUOTE>
98
99 Here LANGUAGE can be one of <CODE>"portuguese"</CODE>, <CODE>"irish"</CODE>,
100 <CODE>"french"</CODE>, <CODE>"latin-2"</CODE>, <CODE>"latin-1"</CODE>.
101 <P>Since the Linux default compose character is Ctrl-.
102 it might be convenient to use that everywhere. Try
103 <BLOCKQUOTE><CODE>
104 <PRE>
105         (load-library "iso-insert.el")
106         (define-key global-map [?\C-.] 8859-1-map)
107 </PRE>
108 </CODE></BLOCKQUOTE>
109
110 The latter line will not work under <CODE>xterm</CODE>, if you use <CODE>emacs -nw</CODE>,
111 but in that case you can put
112 <BLOCKQUOTE><CODE>
113 <PRE>
114         XTerm*VT100.Translations:       #override\n\
115               Ctrl &lt;KeyPress> . : string("\0308")
116 </PRE>
117 </CODE></BLOCKQUOTE>
118
119 in your <CODE>.Xresources</CODE>.)
120 <P>B. For <CODE>less</CODE>, put <CODE>LESSCHARSET=latin1</CODE> in the environment.
121 This is also what you need if you see <CODE>\255</CODE> or <CODE>&lt;AD&gt;</CODE>
122 in <CODE>man</CODE> output: some versions of <CODE>less</CODE> will render the soft hyphen
123 (octal 0255, hex 0xAD) this way when not given permission to output Latin-1.
124 <P>C. For <CODE>ls</CODE>, give the option <CODE>-N</CODE>. (Probably you want to make an alias.)
125 <P>D. For <CODE>bash</CODE> (version 1.13.*), put
126 <BLOCKQUOTE><CODE>
127 <PRE>
128         set meta-flag on
129         set convert-meta off
130         set output-meta on
131 </PRE>
132 </CODE></BLOCKQUOTE>
133
134 into your <CODE>$HOME/.inputrc</CODE>.
135 <P>E. For <CODE>tcsh</CODE>, use
136 <BLOCKQUOTE><CODE>
137 <PRE>
138         setenv LANG     US_en
139         setenv LC_CTYPE iso_8859_1
140 </PRE>
141 </CODE></BLOCKQUOTE>
142
143 If you have nls on your system, then the corresponding routines are used.
144 Otherwise <CODE>tcsh</CODE> will assume iso_8859_1, regardless of the values given to
145 LANG and LC_CTYPE. See the section NATIVE LANGUAGE SYSTEM in tcsh(1).
146 (The Danish HOWTO says: <CODE>setenv LC_CTYPE ISO-8859-1; stty pass8</CODE>)
147 <P>F. For <CODE>flex</CODE>, give the option <CODE>-8</CODE> if the parser it generates must be
148 able to handle 8-bit input. (Of course it must.)
149 <P>G. For <CODE>elm</CODE>, set <CODE>displaycharset</CODE> to <CODE>ISO-8859-1</CODE>.
150 (Danish HOWTO: <CODE>LANG=C</CODE> and <CODE>LC_CTYPE=ISO-8859-1</CODE>)
151 <P>H. For programs using curses (such as <CODE>lynx</CODE>) David Sibley reports:
152 The regular curses package uses the high-order bit for reverse video mode
153 (see flag _STANDOUT defined in <CODE>/usr/include/curses.h</CODE>).  However,
154 <CODE>ncurses</CODE> seems to be 8-bit clean and does display iso-latin-8859-1
155 correctly.
156 <P>I. For programs using <CODE>groff</CODE> (such as <CODE>man</CODE>), make sure to use
157 <CODE>-Tlatin1</CODE> instead of <CODE>-Tascii</CODE>. Old versions of the program <CODE>man</CODE>
158 also use <CODE>col</CODE>, and the next point also applies.
159 <P>J. For <CODE>col</CODE>, make sure 1) that it is fixed so as to do
160 <CODE>setlocale(LC_CTYPE,"");</CODE> and 2) put
161 <CODE>LC_CTYPE=ISO-8859-1</CODE> in the environment.
162 <P>K. For <CODE>rlogin</CODE>, use option <CODE>-8</CODE>.
163 <P>L. For <CODE>joe</CODE>,
164 <CODE>metalab.unc.edu:/pub/Linux/apps/editors/joe-1.0.8-linux.tar.gz</CODE>
165 is said to work after editing the configuration file. Someone else said:
166 <CODE>joe</CODE>: Put the <CODE>-asis</CODE> option in <CODE>/isr/lib/joerc</CODE> in the
167 first column.
168 <P>M. For LaTeX: <CODE>\documentstyle[isolatin]{article}</CODE>.
169 For LaTeX2e: <CODE>\documentclass{article}\usepackage{isolatin}</CODE>
170 where <CODE>isolatin.sty</CODE> is available from
171 <A HREF="ftp://ftp.vlsivie.tuwien.ac.at/pub/8bit">ftp.vlsivie.tuwien.ac.at/pub/8bit</A>.
172 <P>A nice discussion on the topic of ISO-8859-1 and how to manage 8-bit
173 characters is contained in the file <CODE>grasp.insa-lyon.fr:/pub/faq/fr/accents</CODE>
174 (in French). Another fine discussion (in English) can be found in
175 <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>.
176 <P>If you need to fix a program that behaves badly with 8-bit characters,
177 one thing to keep in mind is that if you have a signed char type then
178 characters may be negative, and using them as an array index will fail.
179 Several programs can be fixed by judiciously adding (unsigned char) casts.
180 <P>
181 <HR>
182 <A HREF="kbd.FAQ-13.html">Next</A>
183 <A HREF="kbd.FAQ-11.html">Previous</A>
184 <A HREF="kbd.FAQ.html#toc12">Contents</A>
185 </BODY>
186 </HTML>