(Fbyte_code): Convert a unibyte character to multibyte if necessary.
[bpt/emacs.git] / src / character.h
CommitLineData
0168c3d8
KH
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) 2001, 2002
5 National Institute of Advanced Industrial Science and Technology (AIST)
6 Registration Number H13PRO009
7
8This file is part of GNU Emacs.
9
10GNU Emacs is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 2, or (at your option)
13any later version.
14
15GNU Emacs is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with GNU Emacs; see the file COPYING. If not, write to
22the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23Boston, MA 02111-1307, USA. */
24
25#ifndef EMACS_CHARACTER_H
26#define EMACS_CHARACTER_H
27
885317d8
KH
28/* character code 1st byte byte sequence
29 -------------- -------- -------------
30 0-7F 00..7F 0xxxxxxx
31 80-7FF C2..DF 110xxxxx 10xxxxxx
32 800-FFFF E0..EF 1110xxxx 10xxxxxx 10xxxxxx
33 10000-1FFFFF F0..F7 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
34 200000-3FFF7F F8 11111000 1000xxxx 10xxxxxx 10xxxxxx 10xxxxxx
35 invalid F9..FF
0168c3d8
KH
36
37 raw-8-bit
885317d8 38 3FFF80-3FFFFF C0..C1 1100000x 10xxxxxx
0168c3d8
KH
39*/
40
885317d8 41/* Maximum character code ((1 << CHARACTERBITS) - 1). */
0168c3d8
KH
42#define MAX_CHAR 0x3FFFFF
43
885317d8 44/* Maximum Unicode character code. */
0168c3d8
KH
45#define MAX_UNICODE_CHAR 0x10FFFF
46
885317d8 47/* Maximum N-byte character codes. */
0168c3d8
KH
48#define MAX_1_BYTE_CHAR 0x7F
49#define MAX_2_BYTE_CHAR 0x7FF
50#define MAX_3_BYTE_CHAR 0xFFFF
51#define MAX_4_BYTE_CHAR 0x1FFFFF
52#define MAX_5_BYTE_CHAR 0x3FFF7F
53
8bc28f69
KH
54/* Nonzero iff C is a character that corresponds to a raw 8-bit
55 byte. */
56#define CHAR_BYTE8_P(c) ((c) > MAX_5_BYTE_CHAR)
57
885317d8 58/* Return the character code for raw 8-bit byte BYTE. */
0168c3d8 59#define BYTE8_TO_CHAR(byte) ((byte) + 0x3FFF00)
885317d8
KH
60
61/* Return the raw 8-bit byte for character C. */
8bc28f69
KH
62#define CHAR_TO_BYTE8(c) \
63 (CHAR_BYTE8_P (c) \
64 ? (c) - 0x3FFF00 \
65 : multibyte_char_to_unibyte (c, Qnil))
885317d8
KH
66
67/* Nonzero iff BYTE is the 1st byte of a multibyte form of a character
68 that corresponds to a raw 8-bit byte. */
0168c3d8
KH
69#define CHAR_BYTE8_HEAD_P(byte) ((byte) == 0xC0 || (byte) == 0xC1)
70
3e411074
KH
71/* If C is not ASCII, make it unibyte. */
72
73#define MAKE_CHAR_UNIBYTE(c) \
74 if (! ASCII_CHAR_P (c)) \
75 c = multibyte_char_to_unibyte (c, Qnil); \
76 else
77
78
79/* If C is not ASCII, make it multibyte. */
80
81#define MAKE_CHAR_MULTIBYTE(c) \
82 if (! ASCII_CHAR_P (c)) \
83 c = unibyte_char_to_multibyte (c); \
84 else
85
86
885317d8 87/* This is the maximum byte length of multibyte form. */
0168c3d8
KH
88#define MAX_MULTIBYTE_LENGTH 5
89
885317d8 90/* Return a Lisp character whose character code is C. */
0168c3d8
KH
91#define make_char(c) make_number (c)
92
93/* Nonzero iff C is an ASCII byte. */
94#define ASCII_BYTE_P(c) ((unsigned) (c) < 0x80)
95
96/* Nonzero iff X is a character. */
97#define CHARACTERP(x) (NATNUMP (x) && XFASTINT (x) <= MAX_CHAR)
98
f65c6d94 99/* Nonzero iff C is valid as a character code. GENERICP is not used
885317d8
KH
100 now. */
101#define CHAR_VALID_P(c, genericp) ((unsigned) (c) <= MAX_CHAR)
0168c3d8
KH
102
103/* Check if Lisp object X is a character or not. */
104#define CHECK_CHARACTER(x) \
105 do { \
106 if (! CHARACTERP(x)) x = wrong_type_argument (Qcharacterp, (x)); \
107 } while (0)
108
109/* Nonzero iff C is an ASCII character. */
110#define ASCII_CHAR_P(c) ((unsigned) (c) < 0x80)
111
112/* Nonzero iff C is a character of code less than 0x100. */
113#define SINGLE_BYTE_CHAR_P(c) ((unsigned) (c) < 0x100)
114
115/* Nonzero if character C has a printable glyph. */
116#define CHAR_PRINTABLE_P(c) \
117 (((c) >= 32 && ((c) < 127) \
118 || ! NILP (CHAR_TABLE_REF (Vprintable_chars, (c)))))
119
885317d8 120/* Return byte length of multibyte form for character C. */
0168c3d8
KH
121#define CHAR_BYTES(c) \
122 ( (c) <= MAX_1_BYTE_CHAR ? 1 \
123 : (c) <= MAX_2_BYTE_CHAR ? 2 \
124 : (c) <= MAX_3_BYTE_CHAR ? 3 \
125 : (c) <= MAX_4_BYTE_CHAR ? 4 \
126 : (c) <= MAX_5_BYTE_CHAR ? 5 \
127 : 2)
128
885317d8
KH
129/* Store multibyte form of the character C in P. The caller should
130 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
131 Returns the length of the multibyte form. */
0168c3d8
KH
132
133#define CHAR_STRING(c, p) \
134 ((unsigned) (c) <= MAX_1_BYTE_CHAR \
135 ? ((p)[0] = (c), \
136 1) \
137 : (unsigned) (c) <= MAX_2_BYTE_CHAR \
138 ? ((p)[0] = (0xC0 | ((c) >> 6)), \
139 (p)[1] = (0x80 | ((c) & 0x3F)), \
140 2) \
141 : (unsigned) (c) <= MAX_3_BYTE_CHAR \
142 ? ((p)[0] = (0xE0 | ((c) >> 12)), \
143 (p)[1] = (0x80 | (((c) >> 6) & 0x3F)), \
144 (p)[2] = (0x80 | ((c) & 0x3F)), \
145 3) \
146 : (unsigned) (c) <= MAX_5_BYTE_CHAR \
885317d8 147 ? char_string_with_unification (c, p) \
0168c3d8
KH
148 : ((p)[0] = (0xC0 | (((c) >> 6) & 0x01)), \
149 (p)[1] = (0x80 | ((c) & 0x3F)), \
150 2))
151
1106ea2b
KH
152/* Store multibyte form of eight-bit char B in P. The caller should
153 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
154 Returns the length of the multibyte form. */
155
156#define BYTE8_STRING(b, p) \
157 ((p)[0] = (0xC0 | (((b) >> 6) & 0x01)), \
158 (p)[1] = (0x80 | ((c) & 0x3F)), \
159 2)
160
0168c3d8 161
885317d8
KH
162/* Store multibyte form of the character C in P. The caller should
163 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
164 And, advance P to the end of the multibyte form. */
0168c3d8 165
885317d8
KH
166#define CHAR_STRING_ADVANCE(c, p) \
167 do { \
168 if ((c) <= MAX_1_BYTE_CHAR) \
169 *(p)++ = (c); \
170 else if ((c) <= MAX_2_BYTE_CHAR) \
171 *(p)++ = (0xC0 | ((c) >> 6)), \
172 *(p)++ = (0x80 | ((c) & 0x3F)); \
173 else if ((c) <= MAX_3_BYTE_CHAR) \
174 *(p)++ = (0xE0 | ((c) >> 12)), \
175 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \
176 *(p)++ = (0x80 | ((c) & 0x3F)); \
177 else if ((c) <= MAX_5_BYTE_CHAR) \
178 (p) += char_string_with_unification ((c), (p)); \
179 else \
180 *(p)++ = (0xC0 | (((c) >> 6) & 0x01)), \
181 *(p)++ = (0x80 | ((c) & 0x3F)); \
182 } while (0)
0168c3d8
KH
183
184/* Nonzero iff BYTE starts a non-ASCII character in a multibyte
185 form. */
186#define LEADING_CODE_P(byte) (((byte) & 0xC0) == 0xC0)
187
b5c7dbe6
KH
188/* Nonzero iff BYTE is a trailing code of a non-ASCII character in a
189 multibyte form. */
190#define TRAILING_CODE_P(byte) (((byte) & 0xC0) == 0x80)
191
885317d8
KH
192/* Nonzero iff BYTE starts a character in a multibyte form.
193 This is equivalent to:
194 (ASCII_BYTE_P (byte) || LEADING_CODE_P (byte)) */
195#define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80)
196
0168c3d8
KH
197/* Just kept for backward compatibility. This macro will be removed
198 in the future. */
199#define BASE_LEADING_CODE_P LEADING_CODE_P
200
201/* How many bytes a character that starts with BYTE occupies in a
202 multibyte form. */
203#define BYTES_BY_CHAR_HEAD(byte) \
204 (!((byte) & 0x80) ? 1 \
205 : !((byte) & 0x20) ? 2 \
206 : !((byte) & 0x10) ? 3 \
207 : !((byte) & 0x08) ? 4 \
208 : 5)
209
210
211/* Return the length of the multi-byte form at string STR of length
212 LEN while assuming that STR points a valid multi-byte form. As
213 this macro isn't necessary anymore, all callers will be changed to
214 use BYTES_BY_CHAR_HEAD directly in the future. */
215
216#define MULTIBYTE_FORM_LENGTH(str, len) \
217 BYTES_BY_CHAR_HEAD (*(str))
218
219/* Parse multibyte string STR of length LENGTH and set BYTES to the
220 byte length of a character at STR while assuming that STR points a
221 valid multibyte form. As this macro isn't necessary anymore, all
222 callers will be changed to use BYTES_BY_CHAR_HEAD directly in the
223 future. */
224
225#define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
226 (bytes) = BYTES_BY_CHAR_HEAD (*(str))
227
228/* The byte length of multibyte form at unibyte string P ending at
229 PEND. If STR doesn't point a valid multibyte form, return 0. */
230
231#define MULTIBYTE_LENGTH(p, pend) \
232 (p >= pend ? 0 \
233 : !((p)[0] & 0x80) ? 1 \
234 : ((p + 1 >= pend) || (((p)[1] & 0xC0) != 0x80)) ? 0 \
235 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
236 : ((p + 2 >= pend) || (((p)[2] & 0xC0) != 0x80)) ? 0 \
237 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
238 : ((p + 3 >= pend) || (((p)[3] & 0xC0) != 0x80)) ? 0 \
239 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
240 : ((p + 4 >= pend) || (((p)[4] & 0xC0) != 0x80)) ? 0 \
241 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
242 : 0)
243
244
245/* Like MULTIBYTE_LENGTH but don't check the ending address. */
246
247#define MULTIBYTE_LENGTH_NO_CHECK(p) \
248 (!((p)[0] & 0x80) ? 1 \
249 : ((p)[1] & 0xC0) != 0x80 ? 0 \
250 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
251 : ((p)[2] & 0xC0) != 0x80 ? 0 \
252 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
253 : ((p)[3] & 0xC0) != 0x80 ? 0 \
254 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
255 : ((p)[4] & 0xC0) != 0x80 ? 0 \
256 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
257 : 0)
258
259
260/* Return the character code of character whose multibyte form is at
261 P. The argument LEN is ignored. It will be removed in the
262 future. */
263
264#define STRING_CHAR(p, len) \
265 (!((p)[0] & 0x80) \
266 ? (p)[0] \
267 : ! ((p)[0] & 0x20) \
268 ? (((((p)[0] & 0x1F) << 6) \
269 | ((p)[1] & 0x3F)) \
270 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0)) \
271 : ! ((p)[0] & 0x10) \
272 ? ((((p)[0] & 0x0F) << 12) \
273 | (((p)[1] & 0x3F) << 6) \
274 | ((p)[2] & 0x3F)) \
885317d8 275 : string_char_with_unification ((p), NULL, NULL))
0168c3d8
KH
276
277
278/* Like STRING_CHAR but set ACTUAL_LEN to the length of multibyte
279 form. The argument LEN is ignored. It will be removed in the
280 future. */
281
282#define STRING_CHAR_AND_LENGTH(p, len, actual_len) \
283 (!((p)[0] & 0x80) \
284 ? ((actual_len) = 1, (p)[0]) \
285 : ! ((p)[0] & 0x20) \
286 ? ((actual_len) = 2, \
287 (((((p)[0] & 0x1F) << 6) \
288 | ((p)[1] & 0x3F)) \
289 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0))) \
290 : ! ((p)[0] & 0x10) \
291 ? ((actual_len) = 3, \
292 ((((p)[0] & 0x0F) << 12) \
293 | (((p)[1] & 0x3F) << 6) \
294 | ((p)[2] & 0x3F))) \
885317d8 295 : string_char_with_unification ((p), NULL, &actual_len))
0168c3d8
KH
296
297
298/* Like STRING_CHAR but advacen P to the end of multibyte form. */
299
300#define STRING_CHAR_ADVANCE(p) \
301 (!((p)[0] & 0x80) \
302 ? *(p)++ \
303 : ! ((p)[0] & 0x20) \
304 ? ((p) += 2, \
305 ((((p)[-2] & 0x1F) << 6) \
306 | ((p)[-1] & 0x3F) \
307 | (((unsigned char) (p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \
308 : ! ((p)[0] & 0x10) \
309 ? ((p) += 3, \
310 ((((p)[-3] & 0x0F) << 12) \
311 | (((p)[-2] & 0x3F) << 6) \
312 | ((p)[-1] & 0x3F))) \
885317d8 313 : string_char_with_unification ((p), &(p), NULL))
0168c3d8
KH
314
315
316/* Fetch the "next" character from Lisp string STRING at byte position
317 BYTEIDX, character position CHARIDX. Store it into OUTPUT.
318
319 All the args must be side-effect-free.
320 BYTEIDX and CHARIDX must be lvalues;
321 we increment them past the character fetched. */
322
323#define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
324 if (1) \
325 { \
326 CHARIDX++; \
327 if (STRING_MULTIBYTE (STRING)) \
328 { \
329 unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX]; \
330 int len; \
331 \
332 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
333 BYTEIDX += len; \
334 } \
335 else \
336 OUTPUT = XSTRING (STRING)->data[BYTEIDX++]; \
337 } \
338 else
339
340
341/* Like FETCH_STRING_CHAR_ADVANCE but assumes STRING is multibyte. */
342
343#define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
344 if (1) \
345 { \
346 unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX]; \
347 int len; \
348 \
349 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
350 BYTEIDX += len; \
351 CHARIDX++; \
352 } \
353 else
354
355
356/* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
357 buffer. */
358
359#define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX) \
360 if (1) \
361 { \
362 CHARIDX++; \
363 if (!NILP (current_buffer->enable_multibyte_characters)) \
364 { \
365 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
366 int len; \
367 \
368 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
369 BYTEIDX += len; \
370 } \
371 else \
372 { \
373 OUTPUT = *(BYTE_POS_ADDR (BYTEIDX)); \
374 BYTEIDX++; \
375 } \
376 } \
377 else
378
379
380/* Like FETCH_CHAR_ADVANCE but assumes STRING is multibyte. */
381
382#define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX) \
383 if (1) \
384 { \
385 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
386 int len; \
387 \
388 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
389 BYTEIDX += len; \
390 CHARIDX++; \
391 } \
392 else
393
394
395/* Increase the buffer byte position POS_BYTE of the current buffer to
396 the next character boundary. No range checking of POS. */
397
398#define INC_POS(pos_byte) \
399 do { \
400 unsigned char *p = BYTE_POS_ADDR (pos_byte); \
401 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
402 } while (0)
403
404
405/* Decrease the buffer byte position POS_BYTE of the current buffer to
406 the previous character boundary. No range checking of POS. */
407
408#define DEC_POS(pos_byte) \
409 do { \
410 unsigned char *p; \
411 \
412 pos_byte--; \
413 if (pos_byte < GPT_BYTE) \
414 p = BEG_ADDR + pos_byte - 1; \
415 else \
416 p = BEG_ADDR + GAP_SIZE + pos_byte - 1; \
417 while (!CHAR_HEAD_P (*p)) \
418 { \
419 p--; \
420 pos_byte--; \
421 } \
422 } while (0)
423
424/* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */
425
426#define INC_BOTH(charpos, bytepos) \
427 do \
428 { \
429 (charpos)++; \
430 if (NILP (current_buffer->enable_multibyte_characters)) \
431 (bytepos)++; \
432 else \
433 INC_POS ((bytepos)); \
434 } \
435 while (0)
436
437
438/* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */
439
440#define DEC_BOTH(charpos, bytepos) \
441 do \
442 { \
443 (charpos)--; \
444 if (NILP (current_buffer->enable_multibyte_characters)) \
445 (bytepos)--; \
446 else \
447 DEC_POS ((bytepos)); \
448 } \
449 while (0)
450
451
452/* Increase the buffer byte position POS_BYTE of the current buffer to
453 the next character boundary. This macro relies on the fact that
454 *GPT_ADDR and *Z_ADDR are always accessible and the values are
455 '\0'. No range checking of POS_BYTE. */
456
457#define BUF_INC_POS(buf, pos_byte) \
458 do { \
459 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte); \
460 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
461 } while (0)
462
463
464/* Decrease the buffer byte position POS_BYTE of the current buffer to
465 the previous character boundary. No range checking of POS_BYTE. */
466
467#define BUF_DEC_POS(buf, pos_byte) \
468 do { \
469 unsigned char *p; \
470 pos_byte--; \
471 if (pos_byte < BUF_GPT_BYTE (buf)) \
472 p = BUF_BEG_ADDR (buf) + pos_byte - 1; \
473 else \
474 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - 1; \
475 while (!CHAR_HEAD_P (*p)) \
476 { \
477 p--; \
478 pos_byte--; \
479 } \
480 } while (0)
481
482
fc9d9d2a
KH
483#define MAYBE_UNIFY_CHAR(c) \
484 if (CHAR_TABLE_P (Vchar_unify_table)) \
485 { \
486 Lisp_Object val; \
487 int unified; \
488 \
489 val = CHAR_TABLE_REF (Vchar_unify_table, c); \
490 if (! NILP (val)) \
491 { \
492 if (SYMBOLP (val)) \
493 { \
b5c7dbe6 494 Funify_charset (val, Qnil, Qnil); \
fc9d9d2a
KH
495 val = CHAR_TABLE_REF (Vchar_unify_table, c); \
496 } \
497 if ((unified = XINT (val)) >= 0) \
498 c = unified; \
499 } \
500 } \
0168c3d8
KH
501 else
502
fc9d9d2a 503
0168c3d8
KH
504/* Return the width of ASCII character C. The width is measured by
505 how many columns occupied on the screen when displayed in the
506 current buffer. */
507
508#define ASCII_CHAR_WIDTH(c) \
509 (c < 0x20 \
510 ? (c == '\t' \
511 ? XFASTINT (current_buffer->tab_width) \
512 : (c == '\n' ? 0 : (NILP (current_buffer->ctl_arrow) ? 4 : 2))) \
513 : (c < 0x7f \
514 ? 1 \
515 : ((NILP (current_buffer->ctl_arrow) ? 4 : 2))))
516
517/* Return the width of character C. The width is measured by how many
518 columns occupied on the screen when displayed in the current
519 buffer. */
520
521#define CHAR_WIDTH(c) \
522 (ASCII_CHAR_P (c) \
523 ? ASCII_CHAR_WIDTH (c) \
524 : XINT (CHAR_TABLE_REF (Vchar_width_table, c)))
525
885317d8 526extern int char_string_with_unification P_ ((int, unsigned char *));
b5c7dbe6
KH
527extern int string_char_with_unification P_ ((const unsigned char *,
528 const unsigned char **, int *));
0168c3d8
KH
529
530extern int translate_char P_ ((Lisp_Object, int c));
531extern int char_printable_p P_ ((int c));
532extern void parse_str_as_multibyte P_ ((unsigned char *, int, int *, int *));
533extern int parse_str_to_multibyte P_ ((unsigned char *, int));
534extern int str_as_multibyte P_ ((unsigned char *, int, int, int *));
535extern int str_to_multibyte P_ ((unsigned char *, int, int));
536extern int str_as_unibyte P_ ((unsigned char *, int));
537extern int strwidth P_ ((unsigned char *, int));
538extern int c_string_width P_ ((unsigned char *, int, int, int *, int *));
539extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *));
540
541extern Lisp_Object Vprintable_chars;
542
543extern Lisp_Object Qcharacterp, Qauto_fill_chars;
544extern Lisp_Object Vtranslation_table_vector;
545extern Lisp_Object Vchar_width_table;
546extern Lisp_Object Vchar_direction_table;
547extern Lisp_Object Vchar_unify_table;
548
fac2bdc4
DL
549extern Lisp_Object string_escape_byte8 P_ ((Lisp_Object));
550
0168c3d8
KH
551/* Return a translation table of id number ID. */
552#define GET_TRANSLATION_TABLE(id) \
553 (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
554
555/* A char-table for characters which may invoke auto-filling. */
556extern Lisp_Object Vauto_fill_chars;
557
e18ef64a 558extern Lisp_Object Vchar_script_table;
b5c7dbe6 559
0168c3d8
KH
560/* Copy LEN bytes from FROM to TO. This macro should be used only
561 when a caller knows that LEN is short and the obvious copy loop is
562 faster than calling bcopy which has some overhead. Copying a
563 multibyte sequence of a character is the typical case. */
564
565#define BCOPY_SHORT(from, to, len) \
566 do { \
567 int i = len; \
568 unsigned char *from_p = from, *to_p = to; \
569 while (i--) *to_p++ = *from_p++; \
570 } while (0)
571
572#define DEFSYM(sym, name) \
573 do { (sym) = intern ((name)); staticpro (&(sym)); } while (0)
574
575#endif /* EMACS_CHARACTER_H */