annotate src/charset.h @ 67701:585be7feb122

Typo.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 20 Dec 2005 17:27:35 +0000
parents 547f2b420666
children 3bd95f4f2941 7beb78bc1f8e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
1 /* Header for multibyte character handler.
64770
a0d1312ede66 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
2 Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
67658
547f2b420666 Copyright fixed
Kenichi Handa <handa@m17n.org>
parents: 66376
diff changeset
3 Copyright (C) 1995, 1997, 1998, 2003
547f2b420666 Copyright fixed
Kenichi Handa <handa@m17n.org>
parents: 66376
diff changeset
4 National Institute of Advanced Industrial Science and Technology (AIST)
547f2b420666 Copyright fixed
Kenichi Handa <handa@m17n.org>
parents: 66376
diff changeset
5 Registration Number H14PRO021
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
7 This file is part of GNU Emacs.
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
8
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
10 it under the terms of the GNU General Public License as published by
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
12 any later version.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
17 GNU General Public License for more details.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 You should have received a copy of the GNU General Public License
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 54703
diff changeset
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 54703
diff changeset
22 Boston, MA 02110-1301, USA. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23
29570
825505ff211e (EMACS_CHARSET_H): Renamed from _CHARSET_H.
Kenichi Handa <handa@m17n.org>
parents: 29539
diff changeset
24 #ifndef EMACS_CHARSET_H
825505ff211e (EMACS_CHARSET_H): Renamed from _CHARSET_H.
Kenichi Handa <handa@m17n.org>
parents: 29539
diff changeset
25 #define EMACS_CHARSET_H
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
27 /* #define BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
28
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 /*** GENERAL NOTE on CHARACTER SET (CHARSET) ***
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 A character set ("charset" hereafter) is a meaningful collection
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 (i.e. language, culture, functionality, etc) of characters. Emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 handles multiple charsets at once. Each charset corresponds to one
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
34 of the ISO charsets. Emacs identifies a charset by a unique
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
35 identification number, whereas ISO identifies a charset by a triplet
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
36 of DIMENSION, CHARS and FINAL-CHAR. So, hereafter, just saying
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
37 "charset" means an identification number (integer value).
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
39 The value range of charsets is 0x00, 0x81..0xFE. There are four
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 kinds of charset depending on DIMENSION (1 or 2) and CHARS (94 or
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 96). For instance, a charset of DIMENSION2_CHARS94 contains 94x94
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
42 characters.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 Within Emacs Lisp, a charset is treated as a symbol which has a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 property `charset'. The property value is a vector containing
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
46 various information about the charset. For readability of C code,
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
47 we use the following convention for C variable names:
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 charset_symbol: Emacs Lisp symbol of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 charset_id: Emacs Lisp integer of an identification number of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 charset: C integer of an identification number of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
52 Each charset (except for ascii) is assigned a base leading-code
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
53 (range 0x80..0x9E). In addition, a charset of greater than 0xA0
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (whose base leading-code is 0x9A..0x9D) is assigned an extended
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 leading-code (range 0xA0..0xFE). In this case, each base
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
56 leading-code specifies the allowable range of extended leading-code
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
57 as shown in the table below. A leading-code is used to represent a
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 character in Emacs' buffer and string.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
60 We call a charset which has extended leading-code a "private
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
61 charset" because those are mainly for a charset which is not yet
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 registered by ISO. On the contrary, we call a charset which does
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
63 not have extended leading-code an "official charset".
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ---------------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 charset dimension base leading-code extended leading-code
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ---------------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 0x00 official dim1 -- none -- -- none --
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (ASCII)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 0x01..0x7F --never used--
29539
a6f1d75744d8 (CHARSET_8_BIT_GRAPHIC): Define as 0x80.
Kenichi Handa <handa@m17n.org>
parents: 29004
diff changeset
71 0x80 official dim1 -- none -- -- none --
a6f1d75744d8 (CHARSET_8_BIT_GRAPHIC): Define as 0x80.
Kenichi Handa <handa@m17n.org>
parents: 29004
diff changeset
72 (eight-bit-graphic)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 0x81..0x8F official dim1 same as charset -- none --
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 0x90..0x99 official dim2 same as charset -- none --
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
75 0x9A..0x9D --never used--
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
76 0x9E official dim1 same as charset -- none --
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
77 (eight-bit-control)
29539
a6f1d75744d8 (CHARSET_8_BIT_GRAPHIC): Define as 0x80.
Kenichi Handa <handa@m17n.org>
parents: 29004
diff changeset
78 0x9F --never used--
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 0xA0..0xDF private dim1 0x9A same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 of 1-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 0xE0..0xEF private dim1 0x9B same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 of 2-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 0xF0..0xF4 private dim2 0x9C same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 of 1-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 0xF5..0xFE private dim2 0x9D same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 of 2-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 0xFF --never used--
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ---------------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 /* Definition of special leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 /* Leading-code followed by extended leading-code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 #define LEADING_CODE_PRIVATE_11 0x9A /* for private DIMENSION1 of 1-column */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 #define LEADING_CODE_PRIVATE_12 0x9B /* for private DIMENSION1 of 2-column */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 #define LEADING_CODE_PRIVATE_21 0x9C /* for private DIMENSION2 of 1-column */
19643
1defeafe575b (LEADING_CODE_PRIVATE_22): Comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 19319
diff changeset
97 #define LEADING_CODE_PRIVATE_22 0x9D /* for private DIMENSION2 of 2-column */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
99 #define LEADING_CODE_8_BIT_CONTROL 0x9E /* for `eight-bit-control' */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
100
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 /* Extended leading-code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 /* Start of each extended leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 #define LEADING_CODE_EXT_11 0xA0 /* follows LEADING_CODE_PRIVATE_11 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 #define LEADING_CODE_EXT_12 0xE0 /* follows LEADING_CODE_PRIVATE_12 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 #define LEADING_CODE_EXT_21 0xF0 /* follows LEADING_CODE_PRIVATE_21 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 #define LEADING_CODE_EXT_22 0xF5 /* follows LEADING_CODE_PRIVATE_22 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 /* Maximum value of extended leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 #define LEADING_CODE_EXT_MAX 0xFE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 /* Definition of minimum/maximum charset of each DIMENSION. */
31460
30806f88340f (MIN_CHARSET_OFFICIAL_DIMENSION1): Define it as 0x80, not 0x81.
Kenichi Handa <handa@m17n.org>
parents: 31434
diff changeset
111 #define MIN_CHARSET_OFFICIAL_DIMENSION1 0x80
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 #define MAX_CHARSET_OFFICIAL_DIMENSION1 0x8F
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 #define MIN_CHARSET_OFFICIAL_DIMENSION2 0x90
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 #define MAX_CHARSET_OFFICIAL_DIMENSION2 0x99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 #define MIN_CHARSET_PRIVATE_DIMENSION1 LEADING_CODE_EXT_11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 #define MIN_CHARSET_PRIVATE_DIMENSION2 LEADING_CODE_EXT_21
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
118 /* Maximum value of overall charset identification number. */
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
119 #define MAX_CHARSET 0xFE
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
120
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 /* Definition of special charsets. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
122 #define CHARSET_ASCII 0 /* 0x00..0x7F */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
123 #define CHARSET_8_BIT_CONTROL 0x9E /* 0x80..0x9F */
29539
a6f1d75744d8 (CHARSET_8_BIT_GRAPHIC): Define as 0x80.
Kenichi Handa <handa@m17n.org>
parents: 29004
diff changeset
124 #define CHARSET_8_BIT_GRAPHIC 0x80 /* 0xA0..0xFF */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 extern int charset_latin_iso8859_1; /* ISO8859-1 (Latin-1) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 extern int charset_jisx0208_1978; /* JISX0208.1978 (Japanese Kanji old set) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 extern int charset_jisx0208; /* JISX0208.1983 (Japanese Kanji) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 extern int charset_katakana_jisx0201; /* JISX0201.Kana (Japanese Katakana) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 extern int charset_big5_1; /* Big5 Level 1 (Chinese Traditional) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 extern int charset_big5_2; /* Big5 Level 2 (Chinese Traditional) */
66376
c054783885e0 (charset_mule_unicode_0100_24ff)
Kenichi Handa <handa@m17n.org>
parents: 64770
diff changeset
133 extern int charset_mule_unicode_0100_24ff;
c054783885e0 (charset_mule_unicode_0100_24ff)
Kenichi Handa <handa@m17n.org>
parents: 64770
diff changeset
134 extern int charset_mule_unicode_2500_33ff;
c054783885e0 (charset_mule_unicode_0100_24ff)
Kenichi Handa <handa@m17n.org>
parents: 64770
diff changeset
135 extern int charset_mule_unicode_e000_ffff;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
137 /* Check if CH is an ASCII character or a base leading-code.
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
138 Nowadays, any byte can be the first byte of a character in a
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
139 multibyte buffer/string. So this macro name is not appropriate. */
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
140 #define CHAR_HEAD_P(ch) ((unsigned char) (ch) < 0xA0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 /*** GENERAL NOTE on CHARACTER REPRESENTATION ***
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
144 Firstly, the term "character" or "char" is used for a multilingual
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
145 character (of course, including ASCII characters), not for a byte in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 computer memory. We use the term "code" or "byte" for the latter
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 case.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 A character is identified by charset and one or two POSITION-CODEs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 POSITION-CODE is the position of the character in the charset. A
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 character of DIMENSION1 charset has one POSITION-CODE: POSITION-CODE-1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 A character of DIMENSION2 charset has two POSITION-CODE:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 POSITION-CODE-1 and POSITION-CODE-2. The code range of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 POSITION-CODE is 0x20..0x7F.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 Emacs has two kinds of representation of a character: multi-byte
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
157 form (for buffers and strings) and single-word form (for character
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
158 objects in Emacs Lisp). The latter is called "character code"
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
159 hereafter. Both representations encode the information of charset
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
160 and POSITION-CODE but in a different way (for instance, the MSB of
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 POSITION-CODE is set in multi-byte form).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
163 For details of the multi-byte form, see the section "2. Emacs
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
164 internal format handlers" of `coding.c'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 Emacs uses 19 bits for a character code. The bits are divided into
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 3 fields: FIELD1(5bits):FIELD2(7bits):FIELD3(7bits).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 A character code of DIMENSION1 character uses FIELD2 to hold charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 and FIELD3 to hold POSITION-CODE-1. A character code of DIMENSION2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 character uses FIELD1 to hold charset, FIELD2 and FIELD3 to hold
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 POSITION-CODE-1 and POSITION-CODE-2 respectively.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 More precisely...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
176 FIELD2 of DIMENSION1 character (except for ascii, eight-bit-control,
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
177 and eight-bit-graphic) is "charset - 0x70". This is to make all
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
178 character codes except for ASCII and 8-bit codes greater than 256.
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
179 So, the range of FIELD2 of DIMENSION1 character is 0, 1, or
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
180 0x11..0x7F.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 FIELD1 of DIMENSION2 character is "charset - 0x8F" for official
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 charset and "charset - 0xE0" for private charset. So, the range of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 FIELD1 of DIMENSION2 character is 0x01..0x1E.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
186 -----------------------------------------------------------------------------
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
187 charset FIELD1 (5-bit) FIELD2 (7-bit) FIELD3 (7-bit)
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
188 -----------------------------------------------------------------------------
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
189 ascii 0 0 0x00..0x7F
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
190 eight-bit-control 0 1 0x00..0x1F
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
191 eight-bit-graphic 0 1 0x20..0x7F
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
192 DIMENSION1 0 charset - 0x70 POSITION-CODE-1
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
193 DIMENSION2(o) charset - 0x8F POSITION-CODE-1 POSITION-CODE-2
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
194 DIMENSION2(p) charset - 0xE0 POSITION-CODE-1 POSITION-CODE-2
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
195 -----------------------------------------------------------------------------
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 "(o)": official, "(p)": private
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
197 -----------------------------------------------------------------------------
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 /* Masks of each field of character code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 #define CHAR_FIELD1_MASK (0x1F << 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 #define CHAR_FIELD2_MASK (0x7F << 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 #define CHAR_FIELD3_MASK 0x7F
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 /* Macros to access each field of character C. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 #define CHAR_FIELD1(c) (((c) & CHAR_FIELD1_MASK) >> 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 #define CHAR_FIELD2(c) (((c) & CHAR_FIELD2_MASK) >> 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 #define CHAR_FIELD3(c) ((c) & CHAR_FIELD3_MASK)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 /* Minimum character code of character of each DIMENSION. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 #define MIN_CHAR_OFFICIAL_DIMENSION1 \
31460
30806f88340f (MIN_CHARSET_OFFICIAL_DIMENSION1): Define it as 0x80, not 0x81.
Kenichi Handa <handa@m17n.org>
parents: 31434
diff changeset
212 ((0x81 - 0x70) << 7)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 #define MIN_CHAR_PRIVATE_DIMENSION1 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 ((MIN_CHARSET_PRIVATE_DIMENSION1 - 0x70) << 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 #define MIN_CHAR_OFFICIAL_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 ((MIN_CHARSET_OFFICIAL_DIMENSION2 - 0x8F) << 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 #define MIN_CHAR_PRIVATE_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 ((MIN_CHARSET_PRIVATE_DIMENSION2 - 0xE0) << 14)
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
219 /* Maximum character code currently used plus 1. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
220 #define MAX_CHAR (0x1F << 14)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
222 /* 1 if C is a single byte character, else 0. */
54703
42c61598ee66 (SINGLE_BYTE_CHAR_P): Fix macro to avoid warnings from GCC.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
223 #define SINGLE_BYTE_CHAR_P(c) (((unsigned)(c) & 0xFF) == (c))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
225 /* 1 if BYTE is an ASCII character in itself, in multibyte mode. */
20257
7ba68c0e1bee (ASCII_BYTE_P): New macro.
Karl Heuer <kwzh@gnu.org>
parents: 20151
diff changeset
226 #define ASCII_BYTE_P(byte) ((byte) < 0x80)
7ba68c0e1bee (ASCII_BYTE_P): New macro.
Karl Heuer <kwzh@gnu.org>
parents: 20151
diff changeset
227
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
228 /* A char-table containing information on each character set.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
230 Unlike ordinary char-tables, this doesn't contain any nested tables.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 Only the top level elements are used. Each element is a vector of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232 the following information:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237 PLIST.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 CHARSET-ID (integer) is the identification number of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
241 BYTES (integer) is the length of the multi-byte form of a character
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
242 in the charset: one of 1, 2, 3, and 4.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 DIMENSION (integer) is the number of bytes to represent a character: 1 or 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 WIDTH (integer) is the number of columns a character in the charset
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
249 occupies on the screen: one of 0, 1, and 2..
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 DIRECTION (integer) is the rendering direction of characters in the
24777
d9d0dd9ebcb5 (Vcharset_table): Comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 23882
diff changeset
252 charset when rendering. If 0, render from left to right, else
d9d0dd9ebcb5 (Vcharset_table): Comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 23882
diff changeset
253 render from right to left.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 LEADING-CODE-EXT (integer) is the extended leading-code for the
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
259 charset. All charsets of less than 0xA0 have the value 0.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 ISO-FINAL-CHAR (character) is the final character of the
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
262 corresponding ISO 2022 charset. It is -1 for such a character
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
263 that is used only internally (e.g. `eight-bit-control').
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 while encoding to variants of ISO 2022 coding system, one of the
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
267 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR). It
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
268 is -1 for such a character that is used only internally
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
269 (e.g. `eight-bit-control').
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 charset, the value is -1.
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
274
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 LONG-NAME (string) is the long name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 PLIST (property list) may contain any type of information a user
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
282 wants to put and get by functions `put-charset-property' and
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 `get-charset-property' respectively. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 extern Lisp_Object Vcharset_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 /* Macros to access various information of CHARSET in Vcharset_table.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 We provide these macros for efficiency. No range check of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288
28513
1fec001e68c5 (CHARSET_TABLE_ENTRY): Fix comment -- argument is a C int, not a lisp integer.
Ken Raeburn <raeburn@raeburn.org>
parents: 28473
diff changeset
289 /* Return entry of CHARSET (C integer) in Vcharset_table. */
17321
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
290 #define CHARSET_TABLE_ENTRY(charset) \
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
291 XCHAR_TABLE (Vcharset_table)->contents[((charset) == CHARSET_ASCII \
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
292 ? 0 : (charset) + 128)]
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 /* Return information INFO-IDX of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 #define CHARSET_TABLE_INFO(charset, info_idx) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 XVECTOR (CHARSET_TABLE_ENTRY (charset))->contents[info_idx]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 #define CHARSET_ID_IDX (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 #define CHARSET_BYTES_IDX (1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 #define CHARSET_DIMENSION_IDX (2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 #define CHARSET_CHARS_IDX (3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 #define CHARSET_WIDTH_IDX (4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 #define CHARSET_DIRECTION_IDX (5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 #define CHARSET_LEADING_CODE_BASE_IDX (6)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 #define CHARSET_LEADING_CODE_EXT_IDX (7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 #define CHARSET_ISO_FINAL_CHAR_IDX (8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 #define CHARSET_ISO_GRAPHIC_PLANE_IDX (9)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 #define CHARSET_REVERSE_CHARSET_IDX (10)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 #define CHARSET_SHORT_NAME_IDX (11)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 #define CHARSET_LONG_NAME_IDX (12)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 #define CHARSET_DESCRIPTION_IDX (13)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 #define CHARSET_PLIST_IDX (14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 /* Size of a vector of each entry of Vcharset_table. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 #define CHARSET_MAX_IDX (15)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 /* And several more macros to be used frequently. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 #define CHARSET_BYTES(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_BYTES_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 #define CHARSET_DIMENSION(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIMENSION_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 #define CHARSET_CHARS(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_CHARS_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 #define CHARSET_WIDTH(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_WIDTH_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 #define CHARSET_DIRECTION(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIRECTION_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 #define CHARSET_LEADING_CODE_BASE(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_BASE_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 #define CHARSET_LEADING_CODE_EXT(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_EXT_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 #define CHARSET_ISO_FINAL_CHAR(charset) \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
332 XINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_FINAL_CHAR_IDX))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 #define CHARSET_ISO_GRAPHIC_PLANE(charset) \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
334 XINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_GRAPHIC_PLANE_IDX))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 #define CHARSET_REVERSE_CHARSET(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 XINT (CHARSET_TABLE_INFO (charset, CHARSET_REVERSE_CHARSET_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 /* Macros to specify direction of a charset. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 #define CHARSET_DIRECTION_LEFT_TO_RIGHT 0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 #define CHARSET_DIRECTION_RIGHT_TO_LEFT 1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 /* A vector of charset symbol indexed by charset-id. This is used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 only for returning charset symbol from C functions. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 extern Lisp_Object Vcharset_symbol_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 /* Return symbol of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 #define CHARSET_SYMBOL(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 XVECTOR (Vcharset_symbol_table)->contents[charset]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
350 /* 1 if CHARSET is in valid value range, else 0. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 #define CHARSET_VALID_P(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 ((charset) == 0 \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
353 || ((charset) > 0x80 && (charset) <= MAX_CHARSET_OFFICIAL_DIMENSION2) \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
354 || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
355 && (charset) <= MAX_CHARSET) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
356 || ((charset) == CHARSET_8_BIT_CONTROL) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
357 || ((charset) == CHARSET_8_BIT_GRAPHIC))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
359 /* 1 if CHARSET is already defined, else 0. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 #define CHARSET_DEFINED_P(charset) \
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
361 (((charset) >= 0) && ((charset) <= MAX_CHARSET) \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 && !NILP (CHARSET_TABLE_ENTRY (charset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 /* Since the information CHARSET-BYTES and CHARSET-WIDTH of
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
365 Vcharset_table can be retrieved only by the first byte of
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 multi-byte form (an ASCII code or a base leading-code), we provide
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 here tables to be used by macros BYTES_BY_CHAR_HEAD and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 WIDTH_BY_CHAR_HEAD for faster information retrieval. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 extern int bytes_by_char_head[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 extern int width_by_char_head[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
372 #define BYTES_BY_CHAR_HEAD(char_head) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
373 (ASCII_BYTE_P (char_head) ? 1 : bytes_by_char_head[char_head])
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
374 #define WIDTH_BY_CHAR_HEAD(char_head) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
375 (ASCII_BYTE_P (char_head) ? 1 : width_by_char_head[char_head])
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 /* Charset of the character C. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
378 #define CHAR_CHARSET(c) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
379 (SINGLE_BYTE_CHAR_P (c) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
380 ? (ASCII_BYTE_P (c) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
381 ? CHARSET_ASCII \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
382 : (c) < 0xA0 ? CHARSET_8_BIT_CONTROL : CHARSET_8_BIT_GRAPHIC) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
383 : ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
384 ? CHAR_FIELD2 (c) + 0x70 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
385 : ((c) < MIN_CHAR_PRIVATE_DIMENSION2 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
386 ? CHAR_FIELD1 (c) + 0x8F \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
387 : CHAR_FIELD1 (c) + 0xE0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
389 /* Check if two characters C1 and C2 belong to the same charset. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
390 #define SAME_CHARSET_P(c1, c2) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
391 (c1 < MIN_CHAR_OFFICIAL_DIMENSION2 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
392 ? (c1 & CHAR_FIELD2_MASK) == (c2 & CHAR_FIELD2_MASK) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
393 : (c1 & CHAR_FIELD1_MASK) == (c2 & CHAR_FIELD1_MASK))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 /* Return a character of which charset is CHARSET and position-codes
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 are C1 and C2. DIMENSION1 character ignores C2. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
397 #define MAKE_CHAR(charset, c1, c2) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
398 ((charset) == CHARSET_ASCII \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
399 ? (c1) & 0x7F \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
400 : (((charset) == CHARSET_8_BIT_CONTROL \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
401 || (charset) == CHARSET_8_BIT_GRAPHIC) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
402 ? ((c1) & 0x7F) | 0x80 \
30282
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
403 : ((CHARSET_DEFINED_P (charset) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
404 ? CHARSET_DIMENSION (charset) == 1 \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
405 : (charset) < MIN_CHARSET_PRIVATE_DIMENSION2) \
31434
28f0d4e9cbb2 (MAKE_CHAR): Be sure to set MSB of C1 to 0.
Kenichi Handa <handa@m17n.org>
parents: 30282
diff changeset
406 ? (((charset) - 0x70) << 7) | ((c1) <= 0 ? 0 : ((c1) & 0x7F)) \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
407 : ((((charset) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
408 - ((charset) < MIN_CHARSET_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
409 << 14) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
410 | ((c2) <= 0 ? 0 : ((c2) & 0x7F)) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
411 | ((c1) <= 0 ? 0 : (((c1) & 0x7F) << 7))))))
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
412
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413
20151
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
414 /* If GENERICP is nonzero, return nonzero iff C is a valid normal or
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
415 generic character. If GENERICP is zero, return nonzero iff C is a
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
416 valid normal character. */
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
417 #define CHAR_VALID_P(c, genericp) \
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
418 ((c) >= 0 \
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
419 && (SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, genericp)))
17833
59aa4a0772f6 (VALID_CHAR_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 17726
diff changeset
420
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
421 /* This default value is used when nonascii-translation-table or
21033
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
422 nonascii-insert-offset fail to convert unibyte character to a valid
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
423 multibyte character. This makes a Latin-1 character. */
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
424
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
425 #define DEFAULT_NONASCII_INSERT_OFFSET 0x800
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
426
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
427 /* Parse multibyte string STR of length LENGTH and set BYTES to the
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
428 byte length of a character at STR. */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
429
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
430 #ifdef BYTE_COMBINING_DEBUG
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
431
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
432 #define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
433 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
434 int i = 1; \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
435 while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++; \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
436 (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
437 if ((bytes) > i) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
438 abort (); \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
439 } while (0)
21033
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
440
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
441 #else /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
442
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
443 #define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
50628
37a13dfcd8c2 (PARSE_MULTIBYTE_SEQ): Pretend `length' is used.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49314
diff changeset
444 ((void)(length), (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]))
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
445
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
446 #endif /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
447
51351
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
448 #define VALID_LEADING_CODE_P(code) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
449 (! NILP (CHARSET_TABLE_ENTRY (code)))
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
450
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
451 /* Return 1 iff the byte sequence at unibyte string STR (LENGTH bytes)
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
452 is valid as a multibyte form. If valid, by a side effect, BYTES is
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
453 set to the byte length of the multibyte form. */
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
454
51351
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
455 #define UNIBYTE_STR_AS_MULTIBYTE_P(str, length, bytes) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
456 (((str)[0] < 0x80 || (str)[0] >= 0xA0) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
457 ? ((bytes) = 1) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
458 : (((bytes) = BYTES_BY_CHAR_HEAD ((str)[0])), \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
459 ((bytes) <= (length) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
460 && !CHAR_HEAD_P ((str)[1]) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
461 && ((bytes) == 2 \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
462 ? (str)[0] != LEADING_CODE_8_BIT_CONTROL \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
463 : (!CHAR_HEAD_P ((str)[2]) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
464 && ((bytes) == 3 \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
465 ? (((str)[0] != LEADING_CODE_PRIVATE_11 \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
466 && (str)[0] != LEADING_CODE_PRIVATE_12) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
467 || VALID_LEADING_CODE_P (str[1])) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
468 : (!CHAR_HEAD_P ((str)[3]) \
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
469 && VALID_LEADING_CODE_P (str[1]))))))))
32900e49a097 (VALID_LEADING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 50628
diff changeset
470
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
471
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
472 /* Return 1 iff the byte sequence at multibyte string STR is valid as
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
473 a unibyte form. By a side effect, BYTES is set to the byte length
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
474 of one character at STR. */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
475
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
476 #define MULTIBYTE_STR_AS_UNIBYTE_P(str, bytes) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
477 ((bytes) = BYTES_BY_CHAR_HEAD ((str)[0]), \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
478 (str)[0] != LEADING_CODE_8_BIT_CONTROL)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
480 /* The charset of character C is stored in CHARSET, and the
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
481 position-codes of C are stored in C1 and C2.
25583
2c0d3a9d33e8 Lots of comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 25505
diff changeset
482 We store -1 in C2 if the dimension of the charset is 1. */
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
483
30282
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
484 #define SPLIT_CHAR(c, charset, c1, c2) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
485 (SINGLE_BYTE_CHAR_P (c) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
486 ? ((charset \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
487 = (ASCII_BYTE_P (c) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
488 ? CHARSET_ASCII \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
489 : ((c) < 0xA0 ? CHARSET_8_BIT_CONTROL : CHARSET_8_BIT_GRAPHIC))), \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
490 c1 = (c), c2 = -1) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
491 : ((c) & CHAR_FIELD1_MASK \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
492 ? (charset = (CHAR_FIELD1 (c) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
493 + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)), \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
494 c1 = CHAR_FIELD2 (c), \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
495 c2 = CHAR_FIELD3 (c)) \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
496 : (charset = CHAR_FIELD2 (c) + 0x70, \
3d210892f575 (MAKE_CHAR): Return reasonable code even if CHARSET is undefined.
Kenichi Handa <handa@m17n.org>
parents: 29570
diff changeset
497 c1 = CHAR_FIELD3 (c), \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
498 c2 = -1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
500 /* Return 1 iff character C has valid printable glyph. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
501 #define CHAR_PRINTABLE_P(c) (ASCII_BYTE_P (c) || char_printable_p (c))
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
502
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
503 /* The charset of the character at STR is stored in CHARSET, and the
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
504 position-codes are stored in C1 and C2.
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
505 We store -1 in C2 if the character is just 2 bytes. */
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
506
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
507 #define SPLIT_STRING(str, len, charset, c1, c2) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
508 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
509 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
510 || split_string (str, len, &charset, &c1, &c2) < 0) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
511 ? c1 = *(str), charset = CHARSET_ASCII \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 : charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 /* Mapping table from ISO2022's charset (specified by DIMENSION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 CHARS, and FINAL_CHAR) to Emacs' charset. Should be accessed by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 extern int iso_charset_table[2][2][128];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 #define ISO_CHARSET_TABLE(dimension, chars, final_char) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 iso_charset_table[XINT (dimension) - 1][XINT (chars) > 94][XINT (final_char)]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 #define BASE_LEADING_CODE_P(c) (BYTES_BY_CHAR_HEAD ((unsigned char) (c)) > 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
524 /* Return how many bytes C will occupy in a multibyte buffer. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
525 #define CHAR_BYTES(c) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
526 (SINGLE_BYTE_CHAR_P (c) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
527 ? ((ASCII_BYTE_P (c) || (c) >= 0xA0) ? 1 : 2) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
528 : char_bytes (c))
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
529
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 /* The following two macros CHAR_STRING and STRING_CHAR are the main
35478
340a9e4aeb29 comment fixes
Dave Love <fx@gnu.org>
parents: 35408
diff changeset
531 entry points to convert between Emacs's two types of character
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 representations: multi-byte form and single-word form (character
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 code). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
535 /* Store multi-byte form of the character C in STR. The caller should
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
536 allocate at least MAX_MULTIBYTE_LENGTH bytes area at STR in
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
537 advance. Returns the length of the multi-byte form. If C is an
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
538 invalid character code, signal an error. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539
32353
803ca8bc08b2 (CHAR_STRING): Optimized for single byte characters.
Kenichi Handa <handa@m17n.org>
parents: 31703
diff changeset
540 #define CHAR_STRING(c, str) \
803ca8bc08b2 (CHAR_STRING): Optimized for single byte characters.
Kenichi Handa <handa@m17n.org>
parents: 31703
diff changeset
541 (SINGLE_BYTE_CHAR_P (c) \
54703
42c61598ee66 (SINGLE_BYTE_CHAR_P): Fix macro to avoid warnings from GCC.
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
542 ? ((ASCII_BYTE_P (c) || c >= 0xA0) \
32353
803ca8bc08b2 (CHAR_STRING): Optimized for single byte characters.
Kenichi Handa <handa@m17n.org>
parents: 31703
diff changeset
543 ? (*(str) = (unsigned char)(c), 1) \
803ca8bc08b2 (CHAR_STRING): Optimized for single byte characters.
Kenichi Handa <handa@m17n.org>
parents: 31703
diff changeset
544 : (*(str) = LEADING_CODE_8_BIT_CONTROL, *((str)+ 1) = c + 0x20, 2)) \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
545 : char_to_string (c, (unsigned char *) str))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546
38395
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
547 /* Like CHAR_STRING but don't signal an error if C is invalid.
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
548 Value is -1 in this case. */
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
549
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
550 #define CHAR_STRING_NO_SIGNAL(c, str) \
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
551 (SINGLE_BYTE_CHAR_P (c) \
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
552 ? ((ASCII_BYTE_P (c) || c >= 0xA0) \
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
553 ? (*(str) = (unsigned char)(c), 1) \
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
554 : (*(str) = LEADING_CODE_8_BIT_CONTROL, *((str)+ 1) = c + 0x20, 2)) \
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
555 : char_to_string_1 (c, (unsigned char *) str))
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
556
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 /* Return a character code of the character of which multi-byte form
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 is at STR and the length is LEN. If STR doesn't contain valid
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 multi-byte form, only the first byte in STR is returned. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560
23653
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
561 #define STRING_CHAR(str, len) \
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
562 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
563 ? (unsigned char) *(str) \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
564 : string_to_char (str, len, 0))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
566 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to the
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
567 length of the multi-byte form. Just to know the length, use
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 MULTIBYTE_FORM_LENGTH. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
570 #define STRING_CHAR_AND_LENGTH(str, len, actual_len) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
571 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
572 ? ((actual_len) = 1), (unsigned char) *(str) \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
573 : string_to_char (str, len, &(actual_len)))
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
574
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
575 /* Fetch the "next" character from Lisp string STRING at byte position
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
576 BYTEIDX, character position CHARIDX. Store it into OUTPUT.
20589
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
577
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
578 All the args must be side-effect-free.
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
579 BYTEIDX and CHARIDX must be lvalues;
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
580 we increment them past the character fetched. */
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
581
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
582 #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
583 if (1) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
584 { \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
585 CHARIDX++; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
586 if (STRING_MULTIBYTE (STRING)) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
587 { \
46461
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
588 const unsigned char *ptr = SDATA (STRING) + BYTEIDX; \
46441
2eb3c4881e5a (FETCH_STRING_CHAR_ADVANCE, FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SBYTES
Ken Raeburn <raeburn@raeburn.org>
parents: 46421
diff changeset
589 int space_left = SBYTES (STRING) - BYTEIDX; \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
590 int actual_len; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
591 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
592 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
593 BYTEIDX += actual_len; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
594 } \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
595 else \
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 44323
diff changeset
596 OUTPUT = SREF (STRING, BYTEIDX++); \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
597 } \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
598 else
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
599
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
600 /* Like FETCH_STRING_CHAR_ADVANCE but assume STRING is multibyte. */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
601
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
602 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
20589
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
603 if (1) \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
604 { \
46461
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
605 const unsigned char *fetch_string_char_ptr = SDATA (STRING) + BYTEIDX; \
46441
2eb3c4881e5a (FETCH_STRING_CHAR_ADVANCE, FETCH_STRING_CHAR_ADVANCE_NO_CHECK): Use SBYTES
Ken Raeburn <raeburn@raeburn.org>
parents: 46421
diff changeset
606 int fetch_string_char_space_left = SBYTES (STRING) - BYTEIDX; \
20589
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
607 int actual_len; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
608 \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
609 OUTPUT \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
610 = STRING_CHAR_AND_LENGTH (fetch_string_char_ptr, \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
611 fetch_string_char_space_left, actual_len); \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
612 \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
613 BYTEIDX += actual_len; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
614 CHARIDX++; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
615 } \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
616 else
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
617
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
618 /* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
619 buffer. */
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
620
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
621 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
622 if (1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
623 { \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
624 CHARIDX++; \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
625 if (!NILP (current_buffer->enable_multibyte_characters)) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
626 { \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
627 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
628 int space_left = ((CHARIDX < GPT ? GPT_BYTE : Z_BYTE) - BYTEIDX); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
629 int actual_len; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
630 \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
631 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
632 BYTEIDX += actual_len; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
633 } \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
634 else \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
635 { \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
636 OUTPUT = *(BYTE_POS_ADDR (BYTEIDX)); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
637 BYTEIDX++; \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
638 } \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
639 } \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
640 else
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
641
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 /* Return the length of the multi-byte form at string STR of length LEN. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643
21444
0cba6f211d7c (MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
644 #define MULTIBYTE_FORM_LENGTH(str, len) \
0cba6f211d7c (MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
645 (BYTES_BY_CHAR_HEAD (*(unsigned char *)(str)) == 1 \
0cba6f211d7c (MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
646 ? 1 \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 : multibyte_form_length (str, len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648
49275
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
649 /* If P is before LIMIT, advance P to the next character boundary. It
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
650 assumes that P is already at a character boundary of the sane
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
651 mulitbyte form whose end address is LIMIT. */
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
652
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
653 #define NEXT_CHAR_BOUNDARY(p, limit) \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
654 do { \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
655 if ((p) < (limit)) \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
656 (p) += BYTES_BY_CHAR_HEAD (*(p)); \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
657 } while (0)
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
658
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
659
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
660 /* If P is after LIMIT, advance P to the previous character boundary.
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
661 It assumes that P is already at a character boundary of the sane
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
662 mulitbyte form whose beginning address is LIMIT. */
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
663
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
664 #define PREV_CHAR_BOUNDARY(p, limit) \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
665 do { \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
666 if ((p) > (limit)) \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
667 { \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
668 const unsigned char *p0 = (p); \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
669 do { \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
670 p0--; \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
671 } while (p0 >= limit && ! CHAR_HEAD_P (*p0)); \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
672 (p) = (BYTES_BY_CHAR_HEAD (*p0) == (p) - p0) ? p0 : (p) - 1; \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
673 } \
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
674 } while (0)
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
675
3a72263855b4 (NEXT_CHAR_BOUNDARY, PREV_CHAR_BOUNDARY): New macros.
Kenichi Handa <handa@m17n.org>
parents: 46547
diff changeset
676
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
679 /* Increase the buffer byte position POS_BYTE of the current buffer to
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
680 the next character boundary. This macro relies on the fact that
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
681 *GPT_ADDR and *Z_ADDR are always accessible and the values are
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
682 '\0'. No range checking of POS. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
683
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
684 #ifdef BYTE_COMBINING_DEBUG
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
685
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
686 #define INC_POS(pos_byte) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
687 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
688 unsigned char *p = BYTE_POS_ADDR (pos_byte); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
689 if (BASE_LEADING_CODE_P (*p)) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
690 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
691 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
692 len = Z_BYTE - pos_byte; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
693 PARSE_MULTIBYTE_SEQ (p, len, bytes); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
694 pos_byte += bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
695 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
696 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
697 pos_byte++; \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
700 #else /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
701
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
702 #define INC_POS(pos_byte) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
703 do { \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
704 unsigned char *p = BYTE_POS_ADDR (pos_byte); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
705 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
706 } while (0)
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
707
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
708 #endif /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
709
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
710 /* Decrease the buffer byte position POS_BYTE of the current buffer to
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
711 the previous character boundary. No range checking of POS. */
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
712 #define DEC_POS(pos_byte) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
713 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
714 unsigned char *p, *p_min; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
715 \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
716 pos_byte--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
717 if (pos_byte < GPT_BYTE) \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
718 p = BEG_ADDR + pos_byte - BEG_BYTE, p_min = BEG_ADDR; \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
719 else \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
720 p = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE, p_min = GAP_END_ADDR;\
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
721 if (p > p_min && !CHAR_HEAD_P (*p)) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
722 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
723 unsigned char *pend = p--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
724 int len, bytes; \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
725 if (p_min < p - MAX_MULTIBYTE_LENGTH) \
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
726 p_min = p - MAX_MULTIBYTE_LENGTH; \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
727 while (p > p_min && !CHAR_HEAD_P (*p)) p--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
728 len = pend + 1 - p; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
729 PARSE_MULTIBYTE_SEQ (p, len, bytes); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
730 if (bytes == len) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
731 pos_byte -= len - 1; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
732 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
733 } while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
734
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
735 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
736
20904
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
737 #define INC_BOTH(charpos, bytepos) \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
738 do \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
739 { \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
740 (charpos)++; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
741 if (NILP (current_buffer->enable_multibyte_characters)) \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
742 (bytepos)++; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
743 else \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
744 INC_POS ((bytepos)); \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
745 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
746 while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
747
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
748 /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
749
20904
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
750 #define DEC_BOTH(charpos, bytepos) \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
751 do \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
752 { \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
753 (charpos)--; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
754 if (NILP (current_buffer->enable_multibyte_characters)) \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
755 (bytepos)--; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
756 else \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
757 DEC_POS ((bytepos)); \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
758 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
759 while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
760
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
761 /* Increase the buffer byte position POS_BYTE of the current buffer to
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
762 the next character boundary. This macro relies on the fact that
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
763 *GPT_ADDR and *Z_ADDR are always accessible and the values are
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
764 '\0'. No range checking of POS_BYTE. */
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
765
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
766 #ifdef BYTE_COMBINING_DEBUG
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
767
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
768 #define BUF_INC_POS(buf, pos_byte) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
769 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
770 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
771 if (BASE_LEADING_CODE_P (*p)) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
772 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
773 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
774 len = BUF_Z_BYTE (buf) - pos_byte; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
775 PARSE_MULTIBYTE_SEQ (p, len, bytes); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
776 pos_byte += bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
777 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
778 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
779 pos_byte++; \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
780 } while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
781
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
782 #else /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
783
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
784 #define BUF_INC_POS(buf, pos_byte) \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
785 do { \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
786 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
787 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
788 } while (0)
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
789
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
790 #endif /* not BYTE_COMBINING_DEBUG */
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
791
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
792 /* Decrease the buffer byte position POS_BYTE of the current buffer to
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
793 the previous character boundary. No range checking of POS_BYTE. */
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
794 #define BUF_DEC_POS(buf, pos_byte) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
795 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
796 unsigned char *p, *p_min; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
797 pos_byte--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
798 if (pos_byte < BUF_GPT_BYTE (buf)) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
799 { \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
800 p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
801 p_min = BUF_BEG_ADDR (buf); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
802 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
803 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
804 { \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
805 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
806 p_min = BUF_GAP_END_ADDR (buf); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
807 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
808 if (p > p_min && !CHAR_HEAD_P (*p)) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
809 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
810 unsigned char *pend = p--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
811 int len, bytes; \
44323
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
812 if (p_min < p - MAX_MULTIBYTE_LENGTH) \
fcc0f55d734f (DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42473
diff changeset
813 p_min = p - MAX_MULTIBYTE_LENGTH; \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
814 while (p > p_min && !CHAR_HEAD_P (*p)) p--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
815 len = pend + 1 - p; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
816 PARSE_MULTIBYTE_SEQ (p, len, bytes); \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
817 if (bytes == len) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
818 pos_byte -= len - 1; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
819 } \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 #endif /* emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
824 /* This is the maximum byte length of multi-byte sequence. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
825 #define MAX_MULTIBYTE_LENGTH 4
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
826
20932
3c2c8431c51d (INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents: 20904
diff changeset
827 extern void invalid_character P_ ((int));
3c2c8431c51d (INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents: 20904
diff changeset
828
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
829 extern int translate_char P_ ((Lisp_Object, int, int, int, int));
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
830 extern int split_string P_ ((const unsigned char *, int, int *,
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
831 unsigned char *, unsigned char *));
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
832 extern int char_to_string P_ ((int, unsigned char *));
38395
b7a9187751b2 (CHAR_STRING_NO_SIGNAL): New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35949
diff changeset
833 extern int char_to_string_1 P_ ((int, unsigned char *));
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
834 extern int string_to_char P_ ((const unsigned char *, int, int *));
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
835 extern int char_printable_p P_ ((int c));
21419
95aae2ff5fcd (string_to_non_ascii_char, multibyte_form_length)
Karl Heuer <kwzh@gnu.org>
parents: 21416
diff changeset
836 extern int multibyte_form_length P_ ((const unsigned char *, int));
46461
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
837 extern void parse_str_as_multibyte P_ ((const unsigned char *, int, int *,
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
838 int *));
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
839 extern int str_as_multibyte P_ ((unsigned char *, int, int, int *));
35949
6f52e8c1039f (parse_str_to_multibyte): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 35478
diff changeset
840 extern int parse_str_to_multibyte P_ ((unsigned char *, int));
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
841 extern int str_to_multibyte P_ ((unsigned char *, int, int));
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
842 extern int str_as_unibyte P_ ((unsigned char *, int));
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
843 extern int get_charset_id P_ ((Lisp_Object));
46461
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
844 extern int find_charset_in_text P_ ((const unsigned char *, int, int, int *,
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
845 Lisp_Object));
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
846 extern int strwidth P_ ((unsigned char *, int));
46461
7d3969ae9291 (find_charset_in_text, c_string_width):
Ken Raeburn <raeburn@raeburn.org>
parents: 46441
diff changeset
847 extern int c_string_width P_ ((const unsigned char *, int, int, int *, int *));
35408
9a2cf1e0032c (c_string_width, lisp_string_width): Extern them.
Kenichi Handa <handa@m17n.org>
parents: 32353
diff changeset
848 extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *));
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
849 extern int char_bytes P_ ((int));
23810
e473bf3419a9 Declare char_valid_p.
Andreas Schwab <schwab@suse.de>
parents: 23766
diff changeset
850 extern int char_valid_p P_ ((int, int));
17726
b5f2a7d6a2d0 (unify_char): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 17321
diff changeset
851
49314
961191767061 (Funibyte_char_to_multibyte): Export.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49275
diff changeset
852 EXFUN (Funibyte_char_to_multibyte, 1);
961191767061 (Funibyte_char_to_multibyte): Export.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49275
diff changeset
853
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
854 extern Lisp_Object Vtranslation_table_vector;
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
855
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
856 /* Return a translation table of id number ID. */
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
857 #define GET_TRANSLATION_TABLE(id) \
25637
2e3ab6dece24 (GET_TRANSLATION_TABLE): Use XCDR.
Ken Raeburn <raeburn@raeburn.org>
parents: 25583
diff changeset
858 (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
859
23488
958ab288116d (Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 23202
diff changeset
860 /* A char-table for characters which may invoke auto-filling. */
958ab288116d (Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 23202
diff changeset
861 extern Lisp_Object Vauto_fill_chars;
958ab288116d (Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 23202
diff changeset
862
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
863 /* Copy LEN bytes from FROM to TO. This macro should be used only
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
864 when a caller knows that LEN is short and the obvious copy loop is
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
865 faster than calling bcopy which has some overhead. Copying a
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
866 multibyte sequence of a multibyte character is the typical case. */
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
867
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
868 #define BCOPY_SHORT(from, to, len) \
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
869 do { \
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
870 int i = len; \
46547
ac377294d1f1 (BCOPY_SHORT): Source pointer now points to const.
Ken Raeburn <raeburn@raeburn.org>
parents: 46461
diff changeset
871 const unsigned char *from_p = from; \
ac377294d1f1 (BCOPY_SHORT): Source pointer now points to const.
Ken Raeburn <raeburn@raeburn.org>
parents: 46461
diff changeset
872 unsigned char *to_p = to; \
29004
383e4e21306a (LEADING_CODE_8_BIT_CONTROL, CHARSET_8_BIT_CONTROL,
Kenichi Handa <handa@m17n.org>
parents: 28513
diff changeset
873 while (i--) *to_p++ = *from_p++; \
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
874 } while (0)
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
875
29570
825505ff211e (EMACS_CHARSET_H): Renamed from _CHARSET_H.
Kenichi Handa <handa@m17n.org>
parents: 29539
diff changeset
876 #endif /* EMACS_CHARSET_H */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51351
diff changeset
877
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51351
diff changeset
878 /* arch-tag: 3b96db55-4961-481d-ac3e-219f46a2b3aa
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51351
diff changeset
879 (do not change this comment) */