]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/charsets.7
Import of man-pages 1.70
[thirdparty/man-pages.git] / man7 / charsets.7
1 .\" Copyright (c) 1996 Eric S. Raymond <esr@thyrsus.com>
2 .\" and Andries Brouwer <aeb@cwi.nl>
3 .\"
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" This is combined from many sources, including notes by aeb and
10 .\" research by esr. Portions derive from a writeup by Roman Czyborra.
11 .\"
12 .\" Last changed by David Starner <dstarner98@aasaa.ofe.org>.
13 .TH CHARSETS 7 2001-05-07 "Linux" "Linux Programmer's Manual"
14 .SH NAME
15 charsets \- programmer's view of character sets and internationalization
16 .SH DESCRIPTION
17 Linux is an international operating system. Various of its utilities
18 and device drivers (including the console driver) support multilingual
19 character sets including Latin-alphabet letters with diacritical
20 marks, accents, ligatures, and entire non-Latin alphabets including
21 Greek, Cyrillic, Arabic, and Hebrew.
22 .LP
23 This manual page presents a programmer's-eye view of different
24 character-set standards and how they fit together on Linux. Standards
25 discussed include ASCII, ISO 8859, KOI8-R, Unicode, ISO 2022 and
26 ISO 4873. The primary emphasis is on character sets actually used as
27 locale character sets, not the myriad others that can be found in data
28 from other systems.
29 .LP
30 A complete list of charsets used in a officially supported locale in glibc
31 2.2.3 is: ISO-8859-{1,2,3,5,6,7,8,9,13,15}, CP1251, UTF-8, EUC-{KR,JP,TW},
32 KOI8-{R,U}, GB2312, GB18030, GBK, BIG5, BIG5-HKSCS and TIS-620 (in no
33 particular order.) (Romanian may be switching to ISO-8859-16.)
34
35 .SH ASCII
36 ASCII (American Standard Code For Information Interchange) is the original
37 7-bit character set, originally designed for American English. It is
38 currently described by the ECMA-6 standard.
39 .LP
40 Various ASCII variants replacing the dollar sign with other currency
41 symbols and replacing punctuation with non-English alphabetic characters
42 to cover German, French, Spanish and others in 7 bits exist. All are
43 deprecated; GNU libc doesn't support locales whose character sets aren't
44 true supersets of ASCII. (These sets are also known as ISO-646, a close
45 relative of ASCII that permitted replacing these characters.)
46 .LP
47 As Linux was written for hardware designed in the US, it natively
48 supports ASCII.
49
50 .SH ISO 8859
51 ISO 8859 is a series of 15 8-bit character sets all of which have US
52 ASCII in their low (7-bit) half, invisible control characters in
53 positions 128 to 159, and 96 fixed-width graphics in positions 160-255.
54 .LP
55 Of these, the most important is ISO 8859-1 (Latin-1). It is natively
56 supported in the Linux console driver, fairly well supported in X11R6,
57 and is the base character set of HTML.
58 .LP
59 Console support for the other 8859 character sets is available under
60 Linux through user-mode utilities (such as
61 .BR setfont (8))
62 .\" // some distributions still have the deprecated consolechars
63 that modify keyboard bindings and the EGA graphics
64 table and employ the "user mapping" font table in the console
65 driver.
66 .LP
67 Here are brief descriptions of each set:
68 .TP
69 8859-1 (Latin-1)
70 Latin-1 covers most Western European languages such as Albanian, Catalan,
71 Danish, Dutch, English, Faroese, Finnish, French, German, Galician,
72 Irish, Icelandic, Italian, Norwegian, Portuguese, Spanish, and
73 Swedish. The lack of the ligatures Dutch ij, French oe and old-style
74 ,,German`` quotation marks is considered tolerable.
75 .TP
76 8859-2 (Latin-2)
77 Latin-2 supports most Latin-written Slavic and Central European
78 languages: Croatian, Czech, German, Hungarian, Polish, Rumanian,
79 Slovak, and Slovene.
80 .TP
81 8859-3 (Latin-3)
82 Latin-3 is popular with authors of Esperanto, Galician, and Maltese.
83 (Turkish is now written with 8859-9 instead.)
84 .TP
85 8859-4 (Latin-4)
86 Latin-4 introduced letters for Estonian, Latvian, and Lithuanian. It
87 is essentially obsolete; see 8859-10 (Latin-6) and 8859-13 (Latin-7).
88 .TP
89 8859-5
90 Cyrillic letters supporting Bulgarian, Byelorussian, Macedonian,
91 Russian, Serbian and Ukrainian. Ukrainians read the letter `ghe'
92 with downstroke as `heh' and would need a ghe with upstroke to write a
93 correct ghe. See the discussion of KOI8-R below.
94 .TP
95 8859-6
96 Supports Arabic. The 8859-6 glyph table is a fixed font of separate
97 letter forms, but a proper display engine should combine these
98 using the proper initial, medial, and final forms.
99 .TP
100 8859-7
101 Supports Modern Greek.
102 .TP
103 8859-8
104 Supports modern Hebrew without niqud (punctuation signs). Niqud
105 and full-fledged Biblical Hebrew are outside the scope of this
106 character set; under Linux, UTF-8 is the preferred encoding for
107 these.
108 .TP
109 8859-9 (Latin-5)
110 This is a variant of Latin-1 that replaces Icelandic letters with
111 Turkish ones.
112 .TP
113 8859-10 (Latin-6)
114 Latin 6 adds the last Inuit (Greenlandic) and Sami (Lappish) letters
115 that were missing in Latin 4 to cover the entire Nordic area. RFC
116 1345 listed a preliminary and different `latin6'. Skolt Sami still
117 needs a few more accents than these.
118 .TP
119 8859-11
120 This only exists as a rejected draft standard. The draft standard
121 was identical to TIS-620, which is used under Linux for Thai.
122 .TP
123 8859-12
124 This set does not exist. While Vietnamese has been suggested for this
125 space, it does not fit within the 96 (non-combining) characters ISO
126 8859 offers. UTF-8 is the preferred character set for Vietnamese use
127 under Linux.
128 .TP
129 8859-13 (Latin-7)
130 Supports the Baltic Rim languages; in particular, it includes Latvian
131 characters not found in Latin-4.
132 .TP
133 8859-14 (Latin-8)
134 This is the Celtic character set, covering Gaelic and Welsh.
135 This charset also contains the dotted characters needed for Old Irish.
136 .TP
137 8859-15 (Latin-9)
138 This adds the Euro sign and French and Finnish letters that were missing in
139 Latin-1.
140 .TP
141 8859-16 (Latin-10)
142 This set covers many of the languages covered by 8859-2, and supports
143 Romanian more completely then that set does.
144 .SH KOI8-R
145 KOI8-R is a non-ISO character set popular in Russia. The lower half
146 is US ASCII; the upper is a Cyrillic character set somewhat better
147 designed than ISO 8859-5. KOI8-U is a common character set, based off
148 KOI8-R, that has better support for Ukrainian. Neither of these sets
149 are ISO-2022 compatible, unlike the ISO-8859 series.
150 .LP
151 Console support for KOI8-R is available under Linux through user-mode
152 utilities that modify keyboard bindings and the EGA graphics table,
153 and employ the "user mapping" font table in the console driver.
154
155 .\" Thanks to Tomohiro KUBOTA for the following sections about
156 .\" national standards.
157 .SH JIS X 0208
158 JIS X 0208 is a Japanese national standard character set. Though
159 there are some more Japanese national standard character sets (like
160 JIS X 0201, JIS X 0212, and JIS X 0213), this is the most important
161 one. Characters are mapped into a 94x94 two-byte matrix,
162 whose each byte is in the range 0x21-0x7e. Note that JIS X 0208
163 is a character set, not an encoding. This means that JIS X 0208
164 itself is not used for expressing text data. JIS X 0208 is used
165 as a component to construct encodings such as EUC-JP, Shift_JIS,
166 and ISO-2022-JP. EUC-JP is the most important encoding for Linux
167 and includes US ASCII and JIS X 0208. In EUC-JP, JIS X 0208
168 characters are expressed in two bytes, each of which is the
169 JIS X 0208 code plus 0x80.
170
171 .SH KS X 1001
172 KS X 1001 is a Korean national standard character set. Just as
173 JIS X 0208, characters are mapped into a 94x94 two-byte matrix.
174 KS X 1001 is used like JIS X 0208, as a component
175 to construct encodings such as EUC-KR, Johab, and ISO-2022-KR.
176 EUC-KR is the most important encoding for Linux and includes
177 US ASCII and KS X 1001. KS C 5601 is an older name for KS X 1001.
178
179 .SH GB 2312
180 GB 2312 is a mainland Chinese national standard character set used
181 to express simplified Chinese. Just like JIS X 0208, characters are
182 mapped into a 94x94 two-byte matrix used to construct EUC-CN. EUC-CN
183 is the most important encoding for Linux and includes US ASCII and
184 GB 2312. Note that EUC-CN is often called as GB, GB 2312, or CN-GB.
185
186 .SH Big5
187 Big5 is a popular character set in Taiwan to express traditional
188 Chinese. (Big5 is both a character set and an encoding.) It is a
189 superset of US ASCII. Non-ASCII characters are expressed in two
190 bytes. Bytes 0xa1-0xfe are used as leading bytes for two-byte
191 characters. Big5 and its extension is widely used in Taiwan and Hong
192 Kong. It is not ISO 2022-compliant.
193
194 .SH TIS 620
195 TIS 620 is a Thai national standard character set and a superset
196 of US ASCII. Like ISO 8859 series, Thai characters are mapped into
197 0xa1-0xfe. TIS 620 is the only commonly used character set under
198 Linux besides UTF-8 to have combining characters.
199
200 .SH UNICODE
201 Unicode (ISO 10646) is a standard which aims to unambiguously represent every
202 character in every human language. Unicode's structure permits 20.1 bits
203 to encode every character. Since most computers don't include 20.1-bit
204 integers, Unicode is usually encoded as 32-bit integers internally and
205 either a series of 16-bit integers (UTF-16) (needing two 16-bit integers
206 only when encoding certain rare characters) or a series of 8-bit bytes
207 (UTF-8). Information on Unicode is available at <http://www.unicode.com>.
208 .LP
209 Linux represents Unicode using the 8-bit Unicode Transformation Format
210 (UTF-8). UTF-8 is a variable length encoding of Unicode. It uses 1
211 byte to code 7 bits, 2 bytes for 11 bits, 3 bytes for 16 bits, 4 bytes
212 for 21 bits, 5 bytes for 26 bits, 6 bytes for 31 bits.
213 .LP
214 Let 0,1,x stand for a zero, one, or arbitrary bit. A byte 0xxxxxxx
215 stands for the Unicode 00000000 0xxxxxxx which codes the same symbol
216 as the ASCII 0xxxxxxx. Thus, ASCII goes unchanged into UTF-8, and
217 people using only ASCII do not notice any change: not in code, and not
218 in file size.
219 .LP
220 A byte 110xxxxx is the start of a 2-byte code, and 110xxxxx 10yyyyyy
221 is assembled into 00000xxx xxyyyyyy. A byte 1110xxxx is the start
222 of a 3-byte code, and 1110xxxx 10yyyyyy 10zzzzzz is assembled
223 into xxxxyyyy yyzzzzzz.
224 (When UTF-8 is used to code the 31-bit ISO 10646
225 then this progression continues up to 6-byte codes.)
226 .LP
227 For most people who use ISO-8859 character sets, this means that the
228 characters outside of ASCII are now coded with two bytes. This tends
229 to expand ordinary text files by only one or two percent. For Russian
230 or Greek users, this expands ordinary text files by 100%, since text in
231 those languages is mostly outside of ASCII. For Japanese users this means
232 that the 16-bit codes now in common use will take three bytes. While there
233 are algorithmic conversions from some character sets (esp. ISO-8859-1) to
234 Unicode, general conversion requires carrying around conversion tables,
235 which can be quite large for 16-bit codes.
236 .LP
237 Note that UTF-8 is self-synchronizing: 10xxxxxx is a tail, any other
238 byte is the head of a code. Note that the only way ASCII bytes occur
239 in a UTF-8 stream, is as themselves. In particular, there are no
240 embedded NULs or '/'s that form part of some larger code.
241 .LP
242 Since ASCII, and, in particular, NUL and '/', are unchanged, the
243 kernel does not notice that UTF-8 is being used. It does not care at
244 all what the bytes it is handling stand for.
245 .LP
246 Rendering of Unicode data streams is typically handled through
247 `subfont' tables which map a subset of Unicode to glyphs. Internally
248 the kernel uses Unicode to describe the subfont loaded in video RAM.
249 This means that in UTF-8 mode one can use a character set with 512
250 different symbols. This is not enough for Japanese, Chinese and
251 Korean, but it is enough for most other purposes.
252 .LP
253 At the current time, the console driver does not handle combining
254 characters. So Thai, Sioux and any other script needing combining
255 characters can't be handled on the console.
256
257 .SH "ISO 2022 AND ISO 4873"
258 The ISO 2022 and 4873 standards describe a font-control model
259 based on VT100 practice. This model is (partially) supported
260 by the Linux kernel and by
261 .BR xterm (1).
262 It is popular in Japan and Korea.
263 .LP
264 There are 4 graphic character sets, called G0, G1, G2 and G3,
265 and one of them is the current character set for codes with
266 high bit zero (initially G0), and one of them is the current
267 character set for codes with high bit one (initially G1).
268 Each graphic character set has 94 or 96 characters, and is
269 essentially a 7-bit character set. It uses codes either
270 040-0177 (041-0176) or 0240-0377 (0241-0376).
271 G0 always has size 94 and uses codes 041-0176.
272 .LP
273 Switching between character sets is done using the shift functions
274 ^N (SO or LS1), ^O (SI or LS0), ESC n (LS2), ESC o (LS3),
275 ESC N (SS2), ESC O (SS3), ESC ~ (LS1R), ESC } (LS2R), ESC | (LS3R).
276 The function LS\fIn\fP makes character set G\fIn\fP the current one
277 for codes with high bit zero.
278 The function LS\fIn\fPR makes character set G\fIn\fP the current one
279 for codes with high bit one.
280 The function SS\fIn\fP makes character set G\fIn\fP (\fIn\fP=2 or 3)
281 the current one for the next character only (regardless of the value
282 of its high order bit).
283 .LP
284 A 94-character set is designated as G\fIn\fP character set
285 by an escape sequence ESC ( xx (for G0), ESC ) xx (for G1),
286 ESC * xx (for G2), ESC + xx (for G3), where xx is a symbol
287 or a pair of symbols found in the ISO 2375 International
288 Register of Coded Character Sets.
289 For example, ESC ( @ selects the ISO 646 character set as G0,
290 ESC ( A selects the UK standard character set (with pound
291 instead of number sign), ESC ( B selects ASCII (with dollar
292 instead of currency sign), ESC ( M selects a character set
293 for African languages, ESC ( ! A selects the Cuban character
294 set, etc. etc.
295 .LP
296 A 96-character set is designated as G\fIn\fP character set
297 by an escape sequence ESC - xx (for G1), ESC . xx (for G2)
298 or ESC / xx (for G3).
299 For example, ESC - G selects the Hebrew alphabet as G1.
300 .LP
301 A multibyte character set is designated as G\fIn\fP character set
302 by an escape sequence ESC $ xx or ESC $ ( xx (for G0),
303 ESC $ ) xx (for G1), ESC $ * xx (for G2), ESC $ + xx (for G3).
304 For example, ESC $ ( C selects the Korean character set for G0.
305 The Japanese character set selected by ESC $ B has a more
306 recent version selected by ESC & @ ESC $ B.
307 .LP
308 ISO 4873 stipulates a narrower use of character sets, where G0
309 is fixed (always ASCII), so that G1, G2 and G3
310 can only be invoked for codes with the high order bit set.
311 In particular, ^N and ^O are not used anymore, ESC ( xx
312 can be used only with xx=B, and ESC ) xx, ESC * xx, ESC + xx
313 are equivalent to ESC - xx, ESC . xx, ESC / xx, respectively.
314
315 .SH "SEE ALSO"
316 .BR console (4),
317 .BR console_codes (4),
318 .BR console_ioctl (4),
319 .BR ascii (7),
320 .BR iso_8859-1 (7),
321 .BR unicode (7),
322 .BR utf-8 (7)