1 /* Header for multibyte character handler.
2 Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation.
4 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST)
6 Registration Number H13PRO009
8 This file is part of GNU Emacs.
10 GNU Emacs is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or (at
13 your option) any later version.
15 GNU Emacs is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
23 #ifndef EMACS_CHARACTER_H
24 #define EMACS_CHARACTER_H
31 /* character code 1st byte byte sequence
32 -------------- -------- -------------
34 80-7FF C2..DF 110xxxxx 10xxxxxx
35 800-FFFF E0..EF 1110xxxx 10xxxxxx 10xxxxxx
36 10000-1FFFFF F0..F7 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
37 200000-3FFF7F F8 11111000 1000xxxx 10xxxxxx 10xxxxxx 10xxxxxx
38 3FFF80-3FFFFF C0..C1 1100000x 10xxxxxx (for eight-bit-char)
41 invalid 1st byte 80..BF 10xxxxxx
42 F9..FF 11111xxx (xxx != 000)
45 /* Maximum character code ((1 << CHARACTERBITS) - 1). */
46 #define MAX_CHAR 0x3FFFFF
48 /* Maximum Unicode character code. */
49 #define MAX_UNICODE_CHAR 0x10FFFF
51 /* Maximum N-byte character codes. */
52 #define MAX_1_BYTE_CHAR 0x7F
53 #define MAX_2_BYTE_CHAR 0x7FF
54 #define MAX_3_BYTE_CHAR 0xFFFF
55 #define MAX_4_BYTE_CHAR 0x1FFFFF
56 #define MAX_5_BYTE_CHAR 0x3FFF7F
58 /* Minimum leading code of multibyte characters. */
59 #define MIN_MULTIBYTE_LEADING_CODE 0xC0
60 /* Maximum leading code of multibyte characters. Note: this must be
61 updated if we ever increase MAX_CHAR above. */
62 #define MAX_MULTIBYTE_LEADING_CODE 0xF8
64 /* Unicode character values. */
67 NO_BREAK_SPACE
= 0x00A0,
69 ZERO_WIDTH_NON_JOINER
= 0x200C,
70 ZERO_WIDTH_JOINER
= 0x200D,
72 NON_BREAKING_HYPHEN
= 0x2011,
73 LEFT_SINGLE_QUOTATION_MARK
= 0x2018,
74 RIGHT_SINGLE_QUOTATION_MARK
= 0x2019,
75 PARAGRAPH_SEPARATOR
= 0x2029,
76 LEFT_POINTING_ANGLE_BRACKET
= 0x2329,
77 RIGHT_POINTING_ANGLE_BRACKET
= 0x232A,
78 LEFT_ANGLE_BRACKET
= 0x3008,
79 RIGHT_ANGLE_BRACKET
= 0x3009,
80 OBJECT_REPLACEMENT_CHARACTER
= 0xFFFC,
83 /* UTF-8 encodings. Use \x escapes, so they are portable to pre-C11
84 compilers and can be concatenated with ordinary string literals. */
85 #define uLSQM "\xE2\x80\x98" /* U+2018 LEFT SINGLE QUOTATION MARK */
86 #define uRSQM "\xE2\x80\x99" /* U+2019 RIGHT SINGLE QUOTATION MARK */
88 /* Nonzero iff C is a character that corresponds to a raw 8-bit
90 #define CHAR_BYTE8_P(c) ((c) > MAX_5_BYTE_CHAR)
92 /* Return the character code for raw 8-bit byte BYTE. */
93 #define BYTE8_TO_CHAR(byte) ((byte) + 0x3FFF00)
95 #define UNIBYTE_TO_CHAR(byte) \
96 (ASCII_CHAR_P (byte) ? (byte) : BYTE8_TO_CHAR (byte))
98 /* Return the raw 8-bit byte for character C. */
99 #define CHAR_TO_BYTE8(c) (CHAR_BYTE8_P (c) ? (c) - 0x3FFF00 : (c & 0xFF))
101 /* Return the raw 8-bit byte for character C,
102 or -1 if C doesn't correspond to a byte. */
103 #define CHAR_TO_BYTE_SAFE(c) \
104 (ASCII_CHAR_P (c) ? c : (CHAR_BYTE8_P (c) ? (c) - 0x3FFF00 : -1))
106 /* Nonzero iff BYTE is the 1st byte of a multibyte form of a character
107 that corresponds to a raw 8-bit byte. */
108 #define CHAR_BYTE8_HEAD_P(byte) ((byte) == 0xC0 || (byte) == 0xC1)
110 /* If C is not ASCII, make it unibyte. */
111 #define MAKE_CHAR_UNIBYTE(c) \
113 if (! ASCII_CHAR_P (c)) \
114 c = CHAR_TO_BYTE8 (c); \
118 /* If C is not ASCII, make it multibyte. Assumes C < 256. */
119 #define MAKE_CHAR_MULTIBYTE(c) \
120 (eassert ((c) >= 0 && (c) < 256), (c) = UNIBYTE_TO_CHAR (c))
122 /* This is the maximum byte length of multibyte form. */
123 #define MAX_MULTIBYTE_LENGTH 5
125 /* Nonzero iff X is a character. */
126 #define CHARACTERP(x) (FIXNATP (x) && XFIXNAT (x) <= MAX_CHAR)
128 /* Nonzero iff C is valid as a character code. */
129 #define CHAR_VALID_P(c) UNSIGNED_CMP (c, <=, MAX_CHAR)
131 /* Check if Lisp object X is a character or not. */
132 #define CHECK_CHARACTER(x) \
133 CHECK_TYPE (CHARACTERP (x), Qcharacterp, x)
135 #define CHECK_CHARACTER_CAR(x) \
137 Lisp_Object tmp = XCAR (x); \
138 CHECK_CHARACTER (tmp); \
141 #define CHECK_CHARACTER_CDR(x) \
143 Lisp_Object tmp = XCDR (x); \
144 CHECK_CHARACTER (tmp); \
147 /* Nonzero iff C is a character of code less than 0x100. */
148 #define SINGLE_BYTE_CHAR_P(c) UNSIGNED_CMP (c, <, 0x100)
150 /* Nonzero if character C has a printable glyph. */
151 #define CHAR_PRINTABLE_P(c) \
152 (((c) >= 32 && (c) < 127) \
153 || ! NILP (CHAR_TABLE_REF (Vprintable_chars, (c))))
155 /* Return byte length of multibyte form for character C. */
156 #define CHAR_BYTES(c) \
157 ( (c) <= MAX_1_BYTE_CHAR ? 1 \
158 : (c) <= MAX_2_BYTE_CHAR ? 2 \
159 : (c) <= MAX_3_BYTE_CHAR ? 3 \
160 : (c) <= MAX_4_BYTE_CHAR ? 4 \
161 : (c) <= MAX_5_BYTE_CHAR ? 5 \
165 /* Return the leading code of multibyte form of C. */
166 #define CHAR_LEADING_CODE(c) \
167 ((c) <= MAX_1_BYTE_CHAR ? c \
168 : (c) <= MAX_2_BYTE_CHAR ? (0xC0 | ((c) >> 6)) \
169 : (c) <= MAX_3_BYTE_CHAR ? (0xE0 | ((c) >> 12)) \
170 : (c) <= MAX_4_BYTE_CHAR ? (0xF0 | ((c) >> 18)) \
171 : (c) <= MAX_5_BYTE_CHAR ? 0xF8 \
172 : (0xC0 | (((c) >> 6) & 0x01)))
175 /* Store multibyte form of the character C in P. The caller should
176 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
177 Returns the length of the multibyte form. */
179 #define CHAR_STRING(c, p) \
180 (UNSIGNED_CMP (c, <=, MAX_1_BYTE_CHAR) \
183 : UNSIGNED_CMP (c, <=, MAX_2_BYTE_CHAR) \
184 ? ((p)[0] = (0xC0 | ((c) >> 6)), \
185 (p)[1] = (0x80 | ((c) & 0x3F)), \
187 : UNSIGNED_CMP (c, <=, MAX_3_BYTE_CHAR) \
188 ? ((p)[0] = (0xE0 | ((c) >> 12)), \
189 (p)[1] = (0x80 | (((c) >> 6) & 0x3F)), \
190 (p)[2] = (0x80 | ((c) & 0x3F)), \
192 : verify_expr (sizeof (c) <= sizeof (unsigned), char_string (c, p)))
194 /* Store multibyte form of byte B in P. The caller should allocate at
195 least MAX_MULTIBYTE_LENGTH bytes area at P in advance. Returns the
196 length of the multibyte form. */
198 #define BYTE8_STRING(b, p) \
199 ((p)[0] = (0xC0 | (((b) >> 6) & 0x01)), \
200 (p)[1] = (0x80 | ((b) & 0x3F)), \
204 /* Store multibyte form of the character C in P and advance P to the
205 end of the multibyte form. The caller should allocate at least
206 MAX_MULTIBYTE_LENGTH bytes area at P in advance. */
208 #define CHAR_STRING_ADVANCE(c, p) \
210 if ((c) <= MAX_1_BYTE_CHAR) \
212 else if ((c) <= MAX_2_BYTE_CHAR) \
213 *(p)++ = (0xC0 | ((c) >> 6)), \
214 *(p)++ = (0x80 | ((c) & 0x3F)); \
215 else if ((c) <= MAX_3_BYTE_CHAR) \
216 *(p)++ = (0xE0 | ((c) >> 12)), \
217 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \
218 *(p)++ = (0x80 | ((c) & 0x3F)); \
221 verify (sizeof (c) <= sizeof (unsigned)); \
222 (p) += char_string (c, p); \
227 /* Nonzero iff BYTE starts a non-ASCII character in a multibyte
229 #define LEADING_CODE_P(byte) (((byte) & 0xC0) == 0xC0)
231 /* Nonzero iff BYTE is a trailing code of a non-ASCII character in a
233 #define TRAILING_CODE_P(byte) (((byte) & 0xC0) == 0x80)
235 /* Nonzero iff BYTE starts a character in a multibyte form.
236 This is equivalent to:
237 (ASCII_CHAR_P (byte) || LEADING_CODE_P (byte)) */
238 #define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80)
240 /* How many bytes a character that starts with BYTE occupies in a
241 multibyte form. Unlike MULTIBYTE_LENGTH below, this macro does not
242 validate the multibyte form, but looks only at its first byte. */
243 #define BYTES_BY_CHAR_HEAD(byte) \
244 (!((byte) & 0x80) ? 1 \
245 : !((byte) & 0x20) ? 2 \
246 : !((byte) & 0x10) ? 3 \
247 : !((byte) & 0x08) ? 4 \
251 /* The byte length of multibyte form at unibyte string P ending at
252 PEND. If the string doesn't point to a valid multibyte form,
253 return 0. Unlike BYTES_BY_CHAR_HEAD, this macro validates the
256 #define MULTIBYTE_LENGTH(p, pend) \
258 : !((p)[0] & 0x80) ? 1 \
259 : ((p + 1 >= pend) || (((p)[1] & 0xC0) != 0x80)) ? 0 \
260 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
261 : ((p + 2 >= pend) || (((p)[2] & 0xC0) != 0x80)) ? 0 \
262 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
263 : ((p + 3 >= pend) || (((p)[3] & 0xC0) != 0x80)) ? 0 \
264 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
265 : ((p + 4 >= pend) || (((p)[4] & 0xC0) != 0x80)) ? 0 \
266 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
270 /* Like MULTIBYTE_LENGTH, but don't check the ending address. The
271 multibyte form is still validated, unlike BYTES_BY_CHAR_HEAD. */
273 #define MULTIBYTE_LENGTH_NO_CHECK(p) \
274 (!((p)[0] & 0x80) ? 1 \
275 : ((p)[1] & 0xC0) != 0x80 ? 0 \
276 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
277 : ((p)[2] & 0xC0) != 0x80 ? 0 \
278 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
279 : ((p)[3] & 0xC0) != 0x80 ? 0 \
280 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
281 : ((p)[4] & 0xC0) != 0x80 ? 0 \
282 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
285 /* If P is before LIMIT, advance P to the next character boundary.
286 Assumes that P is already at a character boundary of the same
287 multibyte form whose end address is LIMIT. */
289 #define NEXT_CHAR_BOUNDARY(p, limit) \
292 (p) += BYTES_BY_CHAR_HEAD (*(p)); \
296 /* If P is after LIMIT, advance P to the previous character boundary.
297 Assumes that P is already at a character boundary of the same
298 multibyte form whose beginning address is LIMIT. */
300 #define PREV_CHAR_BOUNDARY(p, limit) \
304 const unsigned char *chp = (p); \
307 } while (chp >= limit && ! CHAR_HEAD_P (*chp)); \
308 (p) = (BYTES_BY_CHAR_HEAD (*chp) == (p) - chp) ? chp : (p) - 1; \
312 /* Return the character code of character whose multibyte form is at P. */
314 #define STRING_CHAR(p) \
317 : ! ((p)[0] & 0x20) \
318 ? (((((p)[0] & 0x1F) << 6) \
320 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0)) \
321 : ! ((p)[0] & 0x10) \
322 ? ((((p)[0] & 0x0F) << 12) \
323 | (((p)[1] & 0x3F) << 6) \
325 : string_char ((p), NULL, NULL))
328 /* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte
331 #define STRING_CHAR_AND_LENGTH(p, actual_len) \
333 ? ((actual_len) = 1, (p)[0]) \
334 : ! ((p)[0] & 0x20) \
335 ? ((actual_len) = 2, \
336 (((((p)[0] & 0x1F) << 6) \
338 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0))) \
339 : ! ((p)[0] & 0x10) \
340 ? ((actual_len) = 3, \
341 ((((p)[0] & 0x0F) << 12) \
342 | (((p)[1] & 0x3F) << 6) \
343 | ((p)[2] & 0x3F))) \
344 : string_char ((p), NULL, &actual_len))
347 /* Like STRING_CHAR, but advance P to the end of multibyte form. */
349 #define STRING_CHAR_ADVANCE(p) \
352 : ! ((p)[0] & 0x20) \
354 ((((p)[-2] & 0x1F) << 6) \
356 | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \
357 : ! ((p)[0] & 0x10) \
359 ((((p)[-3] & 0x0F) << 12) \
360 | (((p)[-2] & 0x3F) << 6) \
361 | ((p)[-1] & 0x3F))) \
362 : string_char ((p), &(p), NULL))
365 /* Fetch the "next" character from Lisp string STRING at byte position
366 BYTEIDX, character position CHARIDX. Store it into OUTPUT.
368 All the args must be side-effect-free.
369 BYTEIDX and CHARIDX must be lvalues;
370 we increment them past the character fetched. */
372 #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
376 if (STRING_MULTIBYTE (STRING)) \
378 unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \
381 OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
386 OUTPUT = SREF (STRING, BYTEIDX); \
392 /* Like FETCH_STRING_CHAR_ADVANCE, but return a multibyte character
393 even if STRING is unibyte. */
395 #define FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
399 if (STRING_MULTIBYTE (STRING)) \
401 unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \
404 OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
409 OUTPUT = SREF (STRING, BYTEIDX); \
411 MAKE_CHAR_MULTIBYTE (OUTPUT); \
417 /* Like FETCH_STRING_CHAR_ADVANCE, but assumes STRING is multibyte. */
419 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
422 unsigned char *fetch_ptr = &SDATA (STRING)[BYTEIDX]; \
425 OUTPUT = STRING_CHAR_AND_LENGTH (fetch_ptr, fetch_len); \
426 BYTEIDX += fetch_len; \
432 /* Like FETCH_STRING_CHAR_ADVANCE, but fetch character from the current
435 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX) \
439 if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) \
441 unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \
444 OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
449 OUTPUT = *(BYTE_POS_ADDR (BYTEIDX)); \
456 /* Like FETCH_CHAR_ADVANCE, but assumes the current buffer is multibyte. */
458 #define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX) \
461 unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \
464 OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
471 /* Increment the buffer byte position POS_BYTE of the current buffer to
472 the next character boundary. No range checking of POS. */
474 #define INC_POS(pos_byte) \
476 unsigned char *chp = BYTE_POS_ADDR (pos_byte); \
477 pos_byte += BYTES_BY_CHAR_HEAD (*chp); \
481 /* Decrement the buffer byte position POS_BYTE of the current buffer to
482 the previous character boundary. No range checking of POS. */
484 #define DEC_POS(pos_byte) \
486 unsigned char *chp; \
489 if (pos_byte < GPT_BYTE) \
490 chp = BEG_ADDR + pos_byte - BEG_BYTE; \
492 chp = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE; \
493 while (!CHAR_HEAD_P (*chp)) \
500 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */
502 #define INC_BOTH(charpos, bytepos) \
506 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) \
509 INC_POS ((bytepos)); \
514 /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */
516 #define DEC_BOTH(charpos, bytepos) \
520 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) \
523 DEC_POS ((bytepos)); \
528 /* Increment the buffer byte position POS_BYTE of the current buffer to
529 the next character boundary. This macro relies on the fact that
530 *GPT_ADDR and *Z_ADDR are always accessible and the values are
531 '\0'. No range checking of POS_BYTE. */
533 #define BUF_INC_POS(buf, pos_byte) \
535 unsigned char *chp = BUF_BYTE_ADDRESS (buf, pos_byte); \
536 pos_byte += BYTES_BY_CHAR_HEAD (*chp); \
540 /* Decrement the buffer byte position POS_BYTE of the current buffer to
541 the previous character boundary. No range checking of POS_BYTE. */
543 #define BUF_DEC_POS(buf, pos_byte) \
545 unsigned char *chp; \
547 if (pos_byte < BUF_GPT_BYTE (buf)) \
548 chp = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \
550 chp = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
551 while (!CHAR_HEAD_P (*chp)) \
559 /* Return a non-outlandish value for the tab width. */
561 #define SANE_TAB_WIDTH(buf) \
562 sanitize_tab_width (XFIXNAT (BVAR (buf, tab_width)))
564 sanitize_tab_width (EMACS_INT width
)
566 return 0 < width
&& width
<= 1000 ? width
: 8;
569 /* Return the width of ASCII character C. The width is measured by
570 how many columns C will occupy on the screen when displayed in the
573 #define ASCII_CHAR_WIDTH(c) \
576 ? SANE_TAB_WIDTH (current_buffer) \
577 : (c == '\n' ? 0 : (NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2))) \
580 : ((NILP (BVAR (current_buffer, ctl_arrow)) ? 4 : 2))))
582 /* Return a non-outlandish value for a character width. */
585 sanitize_char_width (EMACS_INT width
)
587 return 0 <= width
&& width
<= 1000 ? width
: 1000;
590 /* Return the width of character C. The width is measured by how many
591 columns C will occupy on the screen when displayed in the current
592 buffer. The name CHARACTER_WIDTH avoids a collision with <limits.h>
593 CHAR_WIDTH when enabled; see ISO/IEC TS 18661-1:2014. */
595 #define CHARACTER_WIDTH(c) \
597 ? ASCII_CHAR_WIDTH (c) \
598 : sanitize_char_width (XFIXNUM (CHAR_TABLE_REF (Vchar_width_table, c))))
600 /* If C is a variation selector, return the index of the
601 variation selector (1..256). Otherwise, return 0. */
603 #define CHAR_VARIATION_SELECTOR_P(c) \
605 : (c) <= 0xFE0F ? (c) - 0xFE00 + 1 \
606 : (c) < 0xE0100 ? 0 \
607 : (c) <= 0xE01EF ? (c) - 0xE0100 + 17 \
610 /* Return true if C is a surrogate. */
613 char_surrogate_p (int c
)
615 return 0xD800 <= c
&& c
<= 0xDFFF;
618 /* Data type for Unicode general category.
620 The order of members must be in sync with the 8th element of the
621 member of unidata-prop-alist (in admin/unidata/unidata-gen.el) for
622 Unicode character property `general-category'. */
625 UNICODE_CATEGORY_UNKNOWN
= 0,
656 } unicode_category_t
;
658 extern EMACS_INT
char_resolve_modifier_mask (EMACS_INT
) ATTRIBUTE_CONST
;
659 extern int char_string (unsigned, unsigned char *);
660 extern int string_char (const unsigned char *,
661 const unsigned char **, int *);
663 extern int translate_char (Lisp_Object
, int c
);
664 extern ptrdiff_t count_size_as_multibyte (const unsigned char *, ptrdiff_t);
665 extern ptrdiff_t str_as_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t,
667 extern ptrdiff_t str_to_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t);
668 extern ptrdiff_t str_as_unibyte (unsigned char *, ptrdiff_t);
669 extern ptrdiff_t str_to_unibyte (const unsigned char *, unsigned char *,
671 extern ptrdiff_t strwidth (const char *, ptrdiff_t);
672 extern ptrdiff_t c_string_width (const unsigned char *, ptrdiff_t, int,
673 ptrdiff_t *, ptrdiff_t *);
674 extern ptrdiff_t lisp_string_width (Lisp_Object
, ptrdiff_t,
675 ptrdiff_t *, ptrdiff_t *);
677 extern Lisp_Object Vchar_unify_table
;
678 extern Lisp_Object
string_escape_byte8 (Lisp_Object
);
680 extern bool alphabeticp (int);
681 extern bool alphanumericp (int);
682 extern bool graphicp (int);
683 extern bool printablep (int);
684 extern bool blankp (int);
686 extern bool confusable_symbol_character_p (int ch
);
688 /* Return a translation table of id number ID. */
689 #define GET_TRANSLATION_TABLE(id) \
690 (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)]))
692 /* Look up the element in char table OBJ at index CH, and return it as
693 an integer. If the element is not a character, return CH itself. */
696 char_table_translate (Lisp_Object obj
, int ch
)
698 /* This internal function is expected to be called with valid arguments,
699 so there is an eassert instead of CHECK_xxx for the sake of speed. */
700 eassert (CHAR_VALID_P (ch
));
701 eassert (CHAR_TABLE_P (obj
));
702 obj
= CHAR_TABLE_REF (obj
, ch
);
703 return CHARACTERP (obj
) ? XFIXNUM (obj
) : ch
;
706 #if defined __GNUC__ && !defined __STRICT_ANSI__
707 # define HEXDIGIT_CONST const
708 # define HEXDIGIT_IS_CONST true
710 # define HEXDIGIT_CONST
711 # define HEXDIGIT_IS_CONST false
713 extern signed char HEXDIGIT_CONST hexdigit
[];
715 /* If C is a hexadecimal digit ('0'-'9', 'a'-'f', 'A'-'F'), return its
716 value (0-15). Otherwise return -1. */
719 char_hexdigit (int c
)
721 return 0 <= c
&& c
<= UCHAR_MAX
? hexdigit
[c
] : -1;
726 #endif /* EMACS_CHARACTER_H */