mount_namespaces.7: wfix
[man-pages.git] / man7 / charsets.7
blob1e28ef361b30ca32da999bb697271370eb99502d
1 .\" Copyright (c) 1996 Eric S. Raymond <esr@thyrsus.com>
2 .\" and Copyright (c) Andries Brouwer <aeb@cwi.nl>
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\" %%%LICENSE_END
10 .\"
11 .\" This is combined from many sources, including notes by aeb and
12 .\" research by esr.  Portions derive from a writeup by Roman Czyborra.
13 .\"
14 .\" Changes also by David Starner <dstarner98@aasaa.ofe.org>.
15 .\"
16 .TH CHARSETS 7 2020-08-13 "Linux" "Linux Programmer's Manual"
17 .SH NAME
18 charsets \- character set standards and internationalization
19 .SH DESCRIPTION
20 This manual page gives an overview on different character set standards
21 and how they were used on Linux before Unicode became ubiquitous.
22 Some of this information is still helpful for people working with legacy
23 systems and documents.
24 .PP
25 Standards discussed include such as
26 ASCII, GB 2312, ISO 8859, JIS, KOI8-R, KS, and Unicode.
27 .PP
28 The primary emphasis is on character sets that were actually used by
29 locale character sets, not the myriad others that could be found in data
30 from other systems.
31 .SS ASCII
32 ASCII (American Standard Code For Information Interchange) is the original
33 7-bit character set, originally designed for American English.
34 Also known as US-ASCII.
35 It is currently described by the ISO 646:1991 IRV
36 (International Reference Version) standard.
37 .PP
38 Various ASCII variants replacing the dollar sign with other currency
39 symbols and replacing punctuation with non-English alphabetic
40 characters to cover German, French, Spanish, and others in 7 bits
41 emerged.
42 All are deprecated;
43 glibc does not support locales whose character sets are not true
44 supersets of ASCII.
45 .PP
46 As Unicode, when using UTF-8, is ASCII-compatible, plain ASCII text
47 still renders properly on modern UTF-8 using systems.
48 .SS ISO 8859
49 ISO 8859 is a series of 15 8-bit character sets, all of which have ASCII
50 in their low (7-bit) half, invisible control characters in positions
51 128 to 159, and 96 fixed-width graphics in positions 160\(en255.
52 .PP
53 Of these, the most important is ISO 8859-1
54 ("Latin Alphabet No .1" / Latin-1).
55 It was widely adopted and supported by different systems,
56 and is gradually being replaced with Unicode.
57 The ISO 8859-1 characters are also the first 256 characters of Unicode.
58 .PP
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 that modify keyboard bindings and the EGA graphics
63 table and employ the "user mapping" font table in the console
64 driver.
65 .PP
66 Here are brief descriptions of each set:
67 .TP
68 8859-1 (Latin-1)
69 Latin-1 covers many West European languages such as Albanian, Basque,
70 Danish, English, Faroese, Galician, Icelandic, Irish, Italian,
71 Norwegian, Portuguese, Spanish, and Swedish.
72 The lack of the ligatures Dutch IJ/ij, French œ, and old-style „German“
73 quotation marks was considered tolerable.
74 .TP
75 8859-2 (Latin-2)
76 Latin-2 supports many Latin-written Central and East European
77 languages such as Bosnian, Croatian, Czech, German, Hungarian, Polish,
78 Slovak, and Slovene.
79 Replacing Romanian ș/ț with ş/ţ was considered tolerable.
80 .TP
81 8859-3 (Latin-3)
82 Latin-3 was designed to cover of Esperanto, Maltese, and Turkish, but
83 8859-9 later superseded it for Turkish.
84 .TP
85 8859-4 (Latin-4)
86 Latin-4 introduced letters for North European languages such as
87 Estonian, Latvian, and Lithuanian, but was superseded by 8859-10 and
88 8859-13.
89 .TP
90 8859-5
91 Cyrillic letters supporting Bulgarian, Byelorussian, Macedonian,
92 Russian, Serbian, and (almost completely) Ukrainian.
93 It was never widely used, see the discussion of KOI8-R/KOI8-U below.
94 .TP
95 8859-6
96 Was created for Arabic.
97 The 8859-6 glyph table is a fixed font of separate
98 letter forms, but a proper display engine should combine these
99 using the proper initial, medial, and final forms.
101 8859-7
102 Was created for Modern Greek in 1987, updated in 2003.
104 8859-8
105 Supports Modern Hebrew without niqud (punctuation signs).
106 Niqud and full-fledged Biblical Hebrew were outside the scope of this
107 character set.
109 8859-9 (Latin-5)
110 This is a variant of Latin-1 that replaces Icelandic letters with
111 Turkish ones.
113 8859-10 (Latin-6)
114 Latin-6 added the Inuit (Greenlandic) and Sami (Lappish) letters that were
115 missing in Latin-4 to cover the entire Nordic area.
117 8859-11
118 Supports the Thai alphabet and is nearly identical to the TIS-620
119 standard.
121 8859-12
122 This set does not exist.
124 8859-13 (Latin-7)
125 Supports the Baltic Rim languages; in particular, it includes Latvian
126 characters not found in Latin-4.
128 8859-14 (Latin-8)
129 This is the Celtic character set, covering Old Irish, Manx, Gaelic,
130 Welsh, Cornish, and Breton.
132 8859-15 (Latin-9)
133 Latin-9 is similar to the widely used Latin-1 but replaces some less
134 common symbols with the Euro sign and French and Finnish letters that
135 were missing in Latin-1.
137 8859-16 (Latin-10)
138 This set covers many Southeast European languages, and most
139 importantly supports Romanian more completely than Latin-2.
140 .SS KOI8-R / KOI8-U
141 KOI8-R is a non-ISO character set popular in Russia before Unicode.
142 The lower half is ASCII;
143 the upper is a Cyrillic character set somewhat better designed than
144 ISO 8859-5.
145 KOI8-U, based on KOI8-R, has better support for Ukrainian.
146 Neither of these sets are ISO-2022 compatible,
147 unlike the ISO 8859 series.
149 Console support for KOI8-R is available under Linux through user-mode
150 utilities that modify keyboard bindings and the EGA graphics table,
151 and employ the "user mapping" font table in the console driver.
152 .SS GB 2312
153 GB 2312 is a mainland Chinese national standard character set used
154 to express simplified Chinese.
155 Just like JIS X 0208, characters are
156 mapped into a 94x94 two-byte matrix used to construct EUC-CN.
157 EUC-CN
158 is the most important encoding for Linux and includes ASCII and
159 GB 2312.
160 Note that EUC-CN is often called as GB, GB 2312, or CN-GB.
161 .SS Big5
162 Big5 was a popular character set in Taiwan to express traditional
163 Chinese.
164 (Big5 is both a character set and an encoding.)
165 It is a superset of ASCII.
166 Non-ASCII characters are expressed in two bytes.
167 Bytes 0xa1\(en0xfe are used as leading bytes for two-byte characters.
168 Big5 and its extension were widely used in Taiwan and Hong Kong.
169 It is not ISO 2022 compliant.
170 .\" Thanks to Tomohiro KUBOTA for the following sections about
171 .\" national standards.
172 .SS JIS X 0208
173 JIS X 0208 is a Japanese national standard character set.
174 Though there are some more Japanese national standard character sets (like
175 JIS X 0201, JIS X 0212, and JIS X 0213), this is the most important one.
176 Characters are mapped into a 94x94 two-byte matrix,
177 whose each byte is in the range 0x21\(en0x7e.
178 Note that JIS X 0208 is a character set, not an encoding.
179 This means that JIS X 0208
180 itself is not used for expressing text data.
181 JIS X 0208 is used
182 as a component to construct encodings such as EUC-JP, Shift_JIS,
183 and ISO-2022-JP.
184 EUC-JP is the most important encoding for Linux
185 and includes ASCII and JIS X 0208.
186 In EUC-JP, JIS X 0208
187 characters are expressed in two bytes, each of which is the
188 JIS X 0208 code plus 0x80.
189 .SS KS X 1001
190 KS X 1001 is a Korean national standard character set.
191 Just as
192 JIS X 0208, characters are mapped into a 94x94 two-byte matrix.
193 KS X 1001 is used like JIS X 0208, as a component
194 to construct encodings such as EUC-KR, Johab, and ISO-2022-KR.
195 EUC-KR is the most important encoding for Linux and includes
196 ASCII and KS X 1001.
197 KS C 5601 is an older name for KS X 1001.
198 .SS ISO 2022 and ISO 4873
199 The ISO 2022 and 4873 standards describe a font-control model
200 based on VT100 practice.
201 This model is (partially) supported
202 by the Linux kernel and by
203 .BR xterm (1).
204 Several ISO 2022-based character encodings have been defined,
205 especially for Japanese.
207 There are 4 graphic character sets, called G0, G1, G2, and G3,
208 and one of them is the current character set for codes with
209 high bit zero (initially G0), and one of them is the current
210 character set for codes with high bit one (initially G1).
211 Each graphic character set has 94 or 96 characters, and is
212 essentially a 7-bit character set.
213 It uses codes either
214 040\(en0177 (041\(en0176) or 0240\(en0377 (0241\(en0376).
215 G0 always has size 94 and uses codes 041\(en0176.
217 Switching between character sets is done using the shift functions
218 \fB\(haN\fP (SO or LS1), \fB\(haO\fP (SI or LS0), ESC n (LS2), ESC o (LS3),
219 ESC N (SS2), ESC O (SS3), ESC \(ti (LS1R), ESC } (LS2R), ESC | (LS3R).
220 The function LS\fIn\fP makes character set G\fIn\fP the current one
221 for codes with high bit zero.
222 The function LS\fIn\fPR makes character set G\fIn\fP the current one
223 for codes with high bit one.
224 The function SS\fIn\fP makes character set G\fIn\fP (\fIn\fP=2 or 3)
225 the current one for the next character only (regardless of the value
226 of its high order bit).
228 A 94-character set is designated as G\fIn\fP character set
229 by an escape sequence ESC ( xx (for G0), ESC ) xx (for G1),
230 ESC * xx (for G2), ESC + xx (for G3), where xx is a symbol
231 or a pair of symbols found in the ISO 2375 International
232 Register of Coded Character Sets.
233 For example, ESC ( @ selects the ISO 646 character set as G0,
234 ESC ( A selects the UK standard character set (with pound
235 instead of number sign), ESC ( B selects ASCII (with dollar
236 instead of currency sign), ESC ( M selects a character set
237 for African languages, ESC ( ! A selects the Cuban character
238 set, and so on.
240 A 96-character set is designated as G\fIn\fP character set
241 by an escape sequence ESC \- xx (for G1), ESC . xx (for G2)
242 or ESC / xx (for G3).
243 For example, ESC \- G selects the Hebrew alphabet as G1.
245 A multibyte character set is designated as G\fIn\fP character set
246 by an escape sequence ESC $ xx or ESC $ ( xx (for G0),
247 ESC $ ) xx (for G1), ESC $ * xx (for G2), ESC $ + xx (for G3).
248 For example, ESC $ ( C selects the Korean character set for G0.
249 The Japanese character set selected by ESC $ B has a more
250 recent version selected by ESC & @ ESC $ B.
252 ISO 4873 stipulates a narrower use of character sets, where G0
253 is fixed (always ASCII), so that G1, G2, and G3
254 can be invoked only for codes with the high order bit set.
255 In particular, \fB\(haN\fP and \fB\(haO\fP are not used anymore, ESC ( xx
256 can be used only with xx=B, and ESC ) xx, ESC * xx, ESC + xx
257 are equivalent to ESC \- xx, ESC . xx, ESC / xx, respectively.
258 .SS TIS-620
259 TIS-620 is a Thai national standard character set and a superset
260 of ASCII.
261 In the same fashion as the ISO 8859 series, Thai characters are mapped into
262 0xa1\(en0xfe.
263 .SS Unicode
264 Unicode (ISO 10646) is a standard which aims to unambiguously represent
265 every character in every human language.
266 Unicode's structure permits 20.1 bits to encode every character.
267 Since most computers don't include 20.1-bit integers, Unicode is
268 usually encoded as 32-bit integers internally and either a series of
269 16-bit integers (UTF-16) (needing two 16-bit integers only when
270 encoding certain rare characters) or a series of 8-bit bytes (UTF-8).
272 Linux represents Unicode using the 8-bit Unicode Transformation Format
273 (UTF-8).
274 UTF-8 is a variable length encoding of Unicode.
275 It uses 1
276 byte to code 7 bits, 2 bytes for 11 bits, 3 bytes for 16 bits, 4 bytes
277 for 21 bits, 5 bytes for 26 bits, 6 bytes for 31 bits.
279 Let 0,1,x stand for a zero, one, or arbitrary bit.
280 A byte 0xxxxxxx
281 stands for the Unicode 00000000 0xxxxxxx which codes the same symbol
282 as the ASCII 0xxxxxxx.
283 Thus, ASCII goes unchanged into UTF-8, and
284 people using only ASCII do not notice any change: not in code, and not
285 in file size.
287 A byte 110xxxxx is the start of a 2-byte code, and 110xxxxx 10yyyyyy
288 is assembled into 00000xxx xxyyyyyy.
289 A byte 1110xxxx is the start
290 of a 3-byte code, and 1110xxxx 10yyyyyy 10zzzzzz is assembled
291 into xxxxyyyy yyzzzzzz.
292 (When UTF-8 is used to code the 31-bit ISO 10646
293 then this progression continues up to 6-byte codes.)
295 For most texts in ISO 8859 character sets, this means that the
296 characters outside of ASCII are now coded with two bytes.
297 This tends
298 to expand ordinary text files by only one or two percent.
299 For Russian
300 or Greek texts, this expands ordinary text files by 100%, since text in
301 those languages is mostly outside of ASCII.
302 For Japanese users this means
303 that the 16-bit codes now in common use will take three bytes.
304 While there are algorithmic conversions from some character sets
305 (especially ISO 8859-1) to Unicode, general conversion requires
306 carrying around conversion tables, which can be quite large for 16-bit
307 codes.
309 Note that UTF-8 is self-synchronizing: 10xxxxxx is a tail, any other
310 byte is the head of a code.
311 Note that the only way ASCII bytes occur
312 in a UTF-8 stream, is as themselves.
313 In particular, there are no
314 embedded NULs (\(aq\e0\(aq) or \(aq/\(aqs that form part of some larger code.
316 Since ASCII, and, in particular, NUL and \(aq/\(aq, are unchanged, the
317 kernel does not notice that UTF-8 is being used.
318 It does not care at
319 all what the bytes it is handling stand for.
321 Rendering of Unicode data streams is typically handled through
322 "subfont" tables which map a subset of Unicode to glyphs.
323 Internally
324 the kernel uses Unicode to describe the subfont loaded in video RAM.
325 This means that in the Linux console in UTF-8 mode, one can use a character
326 set with 512 different symbols.
327 This is not enough for Japanese, Chinese, and
328 Korean, but it is enough for most other purposes.
329 .SH SEE ALSO
330 .BR iconv (1),
331 .BR ascii (7),
332 .BR iso_8859\-1 (7),
333 .BR unicode (7),
334 .BR utf\-8 (7)