OSDN Git Service

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