1 /* Header for character representation.
2 Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation.
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Rewritten by MORIOKA Tomohiko <tomo@m17n.org>. */
24 #ifndef _XEMACS_CHARACTER_H
25 #define _XEMACS_CHARACTER_H
27 #if !defined(MULE) /* unibyte representation */
28 # include "char-1byte.h"
29 #elif !defined(CHAR_IS_UCS4) /* leading-byte representation */
31 #else /* CHAR_IS_UCS4 */
32 # include "char-ucs.h"
33 #endif /* CHAR_IS_UCS4 */
35 /********************************/
37 /* Interface for characters */
39 /********************************/
42 Return whether the given Emchar is valid.
45 Return whether the given Lisp_Object is a character.
47 CHECK_CHAR_COERCE_INT (ch):
48 Signal an error if CH is not a valid character or integer
50 If CH is an integer Lisp_Object, convert it to a character
51 Lisp_Object, but merely by repackaging, without performing
52 tests for char validity.
54 Functions/macros when MULE is defined:
57 Return whether the given Emchar is ASCII.
59 MAKE_CHAR (CHARSET, B1, B2):
60 Return a character whose coded-charset is CHARSET and
61 position-codes are B1 and B2. 1 byte character ignores B2.
63 BREAKUP_CHAR (ch, charset, B1, B2):
64 Break up the given Emchar, and store found coded-charset and
65 position-codes to CHARSET, B1 and B2.
68 Return coded-charset object of Emchar CH.
70 CHAR_LEADING_BYTE (CH):
71 Return Charset-ID of Emchar CH.
74 #define CHAR_INTP(x) (INTP (x) && valid_char_p (XINT (x)))
76 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
78 #ifdef ERROR_CHECK_TYPECHECK
80 INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj);
82 XCHAR_OR_CHAR_INT (Lisp_Object obj)
84 assert (CHAR_OR_CHAR_INTP (obj));
85 return CHARP (obj) ? XCHAR (obj) : XINT (obj);
90 #define XCHAR_OR_CHAR_INT(obj) (CHARP ((obj)) ? XCHAR ((obj)) : XINT ((obj)))
94 #define CHECK_CHAR_COERCE_INT(x) do { \
97 else if (CHAR_INTP (x)) \
98 x = make_char (XINT (x)); \
100 x = wrong_type_argument (Qcharacterp, x); \
103 #endif /* _XEMACS_CHARACTER_H */