/* Header for multibyte character handler.
Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
Licensed to the Free Software Foundation.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H13PRO009
/* Return the character code for raw 8-bit byte BYTE. */
#define BYTE8_TO_CHAR(byte) ((byte) + 0x3FFF00)
+#define UNIBYTE_TO_CHAR(byte) \
+ (ASCII_BYTE_P (byte) ? (byte) : BYTE8_TO_CHAR (byte))
+
/* Return the raw 8-bit byte for character C. */
#define CHAR_TO_BYTE8(c) \
(CHAR_BYTE8_P (c) \
that corresponds to a raw 8-bit byte. */
#define CHAR_BYTE8_HEAD_P(byte) ((byte) == 0xC0 || (byte) == 0xC1)
-/* Mapping table from unibyte chars to multibyte chars. */
-extern int unibyte_to_multibyte_table[256];
-
-/* Convert the unibyte character C to the corresponding multibyte
- character. If C can't be converted, return C. */
-#define unibyte_char_to_multibyte(c) \
- ((c) < 256 ? unibyte_to_multibyte_table[(c)] : (c))
-
-/* Nth element is 1 iff unibyte char N can be mapped to a multibyte
- char. */
-extern char unibyte_has_multibyte_table[256];
-
-#define UNIBYTE_CHAR_HAS_MULTIBYTE_P(c) (unibyte_has_multibyte_table[(c)])
-
/* If C is not ASCII, make it unibyte. */
#define MAKE_CHAR_UNIBYTE(c) \
do { \
/* If C is not ASCII, make it multibyte. Assumes C < 256. */
#define MAKE_CHAR_MULTIBYTE(c) \
- (eassert ((c) >= 0 && (c) < 256), (c) = unibyte_to_multibyte_table[(c)])
+ (eassert ((c) >= 0 && (c) < 256), (c) = UNIBYTE_TO_CHAR (c))
/* This is the maximum byte length of multibyte form. */
#define MAX_MULTIBYTE_LENGTH 5
/* Nonzero if character C has a printable glyph. */
#define CHAR_PRINTABLE_P(c) \
- (((c) >= 32 && ((c) < 127) \
- || ! NILP (CHAR_TABLE_REF (Vprintable_chars, (c)))))
+ (((c) >= 32 && (c) < 127) \
+ || ! NILP (CHAR_TABLE_REF (Vprintable_chars, (c))))
/* Return byte length of multibyte form for character C. */
#define CHAR_BYTES(c) \
} while (0)
/* Return the character code of character whose multibyte form is at
- P. The argument LEN is ignored. It will be removed in the
- future. */
+ P. */
-#define STRING_CHAR(p, len) \
+#define STRING_CHAR(p) \
(!((p)[0] & 0x80) \
? (p)[0] \
: ! ((p)[0] & 0x20) \
/* Like STRING_CHAR, but set ACTUAL_LEN to the length of multibyte
- form. The argument LEN is ignored. It will be removed in the
- future. */
+ form. */
-#define STRING_CHAR_AND_LENGTH(p, len, actual_len) \
+#define STRING_CHAR_AND_LENGTH(p, actual_len) \
(!((p)[0] & 0x80) \
? ((actual_len) = 1, (p)[0]) \
: ! ((p)[0] & 0x20) \
unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
int len; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
+ OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
BYTEIDX += len; \
} \
else \
unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
int len; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
+ OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
BYTEIDX += len; \
} \
else \
unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
int len; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
+ OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
BYTEIDX += len; \
CHARIDX++; \
} \
unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
int len; \
\
- OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
+ OUTPUT= STRING_CHAR_AND_LENGTH (ptr, len); \
BYTEIDX += len; \
} \
else \
unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
int len; \
\
- OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
+ OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
BYTEIDX += len; \
CHARIDX++; \
} \
/* If C is a character to be unified with a Unicode character, return
the unified Unicode character. */
-#define MAYBE_UNIFY_CHAR(c) \
- if (c > MAX_UNICODE_CHAR \
- && CHAR_TABLE_P (Vchar_unify_table)) \
- { \
- Lisp_Object val; \
- int unified; \
- \
- val = CHAR_TABLE_REF (Vchar_unify_table, c); \
- if (! NILP (val)) \
- { \
- if (SYMBOLP (val)) \
- { \
- Funify_charset (val, Qnil, Qnil); \
- val = CHAR_TABLE_REF (Vchar_unify_table, c); \
- } \
- if ((unified = XINT (val)) >= 0) \
- c = unified; \
- } \
- } \
- else
+#define MAYBE_UNIFY_CHAR(c) \
+ do { \
+ if (c > MAX_UNICODE_CHAR && c <= MAX_5_BYTE_CHAR) \
+ { \
+ Lisp_Object val; \
+ val = CHAR_TABLE_REF (Vchar_unify_table, c); \
+ if (INTEGERP (val)) \
+ c = XINT (val); \
+ else if (! NILP (val)) \
+ c = maybe_unify_char (c, val); \
+ } \
+ } while (0)
/* Return the width of ASCII character C. The width is measured by
? ASCII_CHAR_WIDTH (c) \
: XINT (CHAR_TABLE_REF (Vchar_width_table, c)))
+/* If C is a variation selector, return the index numnber of the
+ variation selector (1..256). Otherwise, return 0. */
+
+#define CHAR_VARIATION_SELECTOR_P(c) \
+ ((c) < 0xFE00 ? 0 \
+ : (c) <= 0xFE0F ? (c) - 0xFE00 + 1 \
+ : (c) < 0xE0100 ? 0 \
+ : (c) <= 0xE01EF ? (c) - 0xE0100 + 17 \
+ : 0)
+
+/* If C is a high surrogate, return 1. If C is a low surrogate,
+ return 0. Otherwise, return 0. */
+
+#define CHAR_SURROGATE_PAIR_P(c) \
+ ((c) < 0xD800 ? 0 \
+ : (c) <= 0xDBFF ? 1 \
+ : (c) <= 0xDFFF ? 2 \
+ : 0)
+
+
extern int char_resolve_modifier_mask P_ ((int));
extern int char_string P_ ((unsigned, unsigned char *));
extern int string_char P_ ((const unsigned char *,
} while (0)
#define DEFSYM(sym, name) \
- do { (sym) = intern ((name)); staticpro (&(sym)); } while (0)
+ do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0)
#endif /* EMACS_CHARACTER_H */