#ifndef _XEMACS_CHAR_UCS_H
#define _XEMACS_CHAR_UCS_H
-/* ---------------------------- */
-/* (D) For working with Emchars */
-/* ---------------------------- */
-
#define valid_char_p(ch) 1
-#define CHAR_ASCII_P(c) ((c) <= 0x7F)
+#define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
+
+\f
+typedef struct
+{
+ unsigned char *base;
+ size_t offset;
+ size_t size;
+} Emchar_to_byte_table;
+
+unsigned char
+get_byte_from_character_table (Emchar ch, Emchar_to_byte_table* table);
+
+
+extern Lisp_Object Vcharset_ucs_bmp;
+
+extern Lisp_Object Vcharset_latin_jisx0201;
+extern Emchar latin_jisx0201_to_ucs[94];
+extern Emchar_to_byte_table* ucs_to_latin_jisx0201;
+
+extern Lisp_Object Vcharset_latin_iso8859_2;
+extern Emchar latin_iso8859_2_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_iso8859_2;
+
+extern Lisp_Object Vcharset_latin_iso8859_3;
+extern Emchar latin_iso8859_3_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_iso8859_3;
+
+extern Lisp_Object Vcharset_latin_iso8859_4;
+extern Emchar latin_iso8859_4_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_iso8859_4;
+
+extern Lisp_Object Vcharset_latin_iso8859_9;
+extern Emchar latin_iso8859_9_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_iso8859_9;
+
+extern Lisp_Object Vcharset_latin_viscii_lower;
+extern Emchar latin_viscii_lower_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_viscii_lower;
+
+extern Lisp_Object Vcharset_latin_viscii_upper;
+extern Emchar latin_viscii_upper_to_ucs[96];
+extern Emchar_to_byte_table* ucs_to_latin_viscii_upper;
\f
/************************************************************************/
#define LEADING_BYTE_CONTROL_1 0x81 /* represent normal 80-9F */
-#define CHARSET_ID_OFFSET_94 0x60
+#define CHARSET_ID_OFFSET_94 0x55
#define MIN_CHARSET_ID_PRIVATE_94 (CHARSET_ID_OFFSET_94 + '0')
#define MAX_CHARSET_ID_PRIVATE_94 (CHARSET_ID_OFFSET_94 + '?')
#define CHARSET_ID_OFFSET_96 0x70
+#define LEADING_BYTE_LATIN_VISCII_LOWER (CHARSET_ID_OFFSET_96 + '1')
+#define LEADING_BYTE_LATIN_VISCII_UPPER (CHARSET_ID_OFFSET_96 + '2')
+
/* Right half of ISO 8859-1 */
#define LEADING_BYTE_LATIN_ISO8859_1 (CHARSET_ID_OFFSET_96 + 'A')
\f
/************************************************************************/
-/* Operations on individual bytes */
-/* of any format */
-/************************************************************************/
-
-/* Argument `c' should be (unsigned int) or (unsigned char). */
-/* Note that SP and DEL are not included. */
-
-#define BYTE_ASCII_P(c) ((c) < 0x80)
-#define BYTE_C0_P(c) ((c) < 0x20)
-/* Do some forced casting just to make *sure* things are gotten right. */
-#define BYTE_C1_P(c) ((unsigned int) ((unsigned int) (c) - 0x80) < 0x20)
-
-\f
-/************************************************************************/
/* Information about a particular character set */
/************************************************************************/
/* Final byte of this character set in ISO2022 designating escape sequence */
Bufbyte final;
- /* Number of bytes (1 - 4) required in the internal representation
- for characters in this character set. This is *not* the
- same as the dimension of the character set). */
- unsigned int rep_bytes;
-
/* Number of columns a character in this charset takes up, on TTY
devices. Not used for X devices. */
unsigned int columns;
/* Which half of font to be used to display this character set */
unsigned int graphic;
+
+ /* character->byte mapping table */
+ Emchar_to_byte_table* encoding_table;
+
+ /* byte->character mapping table */
+ Emchar* decoding_table;
};
DECLARE_LRECORD (charset, struct Lisp_Charset);
#define CHARSET_NAME(cs) ((cs)->name)
#define CHARSET_SHORT_NAME(cs) ((cs)->short_name)
#define CHARSET_LONG_NAME(cs) ((cs)->long_name)
-#define CHARSET_REP_BYTES(cs) ((cs)->rep_bytes)
#define CHARSET_COLUMNS(cs) ((cs)->columns)
#define CHARSET_GRAPHIC(cs) ((cs)->graphic)
#define CHARSET_TYPE(cs) ((cs)->type)
#define XCHARSET_NAME(cs) CHARSET_NAME (XCHARSET (cs))
#define XCHARSET_SHORT_NAME(cs) CHARSET_SHORT_NAME (XCHARSET (cs))
#define XCHARSET_LONG_NAME(cs) CHARSET_LONG_NAME (XCHARSET (cs))
-#define XCHARSET_REP_BYTES(cs) CHARSET_REP_BYTES (XCHARSET (cs))
-#define XCHARSET_COLUMNS(cs) CHARSET_COLUMNS (XCHARSET (cs))
#define XCHARSET_GRAPHIC(cs) CHARSET_GRAPHIC (XCHARSET (cs))
#define XCHARSET_TYPE(cs) CHARSET_TYPE (XCHARSET (cs))
#define XCHARSET_DIRECTION(cs) CHARSET_DIRECTION (XCHARSET (cs))
#define CHARSET_BY_ATTRIBUTES(type, final, dir) \
(charset_by_attributes[type][final])
-INLINE int REP_BYTES_BY_FIRST_BYTE (int fb);
-INLINE int
-REP_BYTES_BY_FIRST_BYTE (int fb)
-{
- if ( fb < 0xc0 )
- return 1;
- else if ( fb < 0xe0 )
- return 2;
- else if ( fb < 0xf0 )
- return 3;
- else if ( fb < 0xf8 )
- return 4;
- else if ( fb < 0xfc )
- return 5;
- else
- return 6;
-}
-
\f
/************************************************************************/
/* Dealing with characters */
/* Return a character whose charset is CHARSET and position-codes
- are C1 and C2. TYPE9N character ignores C2.
-
- NOTE: This takes advantage of the fact that
- FIELD2_TO_OFFICIAL_LEADING_BYTE and
- FIELD2_TO_PRIVATE_LEADING_BYTE are the same.
- */
+ are C1 and C2. TYPE9N character ignores C2. */
INLINE Emchar MAKE_CHAR (Lisp_Object charset, int c1, int c2);
INLINE Emchar
return c1;
else if (EQ (charset, Vcharset_control_1))
return c1 | 0x80;
+ else if (EQ (charset, Vcharset_ucs_bmp))
+ return (c1 << 8) | c2;
else if (EQ (charset, Vcharset_latin_iso8859_1))
return c1 | 0x80;
- else if (EQ (charset, Vcharset_greek_iso8859_7))
- return c1 + MIN_CHAR_GREEK - 0x20;
+ else if (EQ (charset, Vcharset_latin_iso8859_2))
+ return latin_iso8859_2_to_ucs[c1 - 32];
+ else if (EQ (charset, Vcharset_latin_iso8859_3))
+ return latin_iso8859_3_to_ucs[c1 - 32];
+ else if (EQ (charset, Vcharset_latin_iso8859_4))
+ return latin_iso8859_4_to_ucs[c1 - 32];
else if (EQ (charset, Vcharset_cyrillic_iso8859_5))
return c1 + MIN_CHAR_CYRILLIC - 0x20;
+ else if (EQ (charset, Vcharset_greek_iso8859_7))
+ return c1 + MIN_CHAR_GREEK - 0x20;
else if (EQ (charset, Vcharset_hebrew_iso8859_8))
return c1 + MIN_CHAR_HEBREW - 0x20;
+ else if (EQ (charset, Vcharset_latin_iso8859_9))
+ return latin_iso8859_9_to_ucs[c1 - 32];
else if (EQ (charset, Vcharset_thai_tis620))
return c1 + MIN_CHAR_THAI - 0x20;
else if (EQ (charset, Vcharset_katakana_jisx0201))
return c1 + MIN_CHAR_HALFWIDTH_KATAKANA - 0x20;
else
return 32;
+ else if (EQ (charset, Vcharset_latin_jisx0201))
+ return latin_jisx0201_to_ucs[c1 - 33];
+ else if (EQ (charset, Vcharset_latin_viscii_lower))
+ return latin_viscii_lower_to_ucs[c1 - 32];
+ else if (EQ (charset, Vcharset_latin_viscii_upper))
+ return latin_viscii_upper_to_ucs[c1 - 32];
else if (XCHARSET_DIMENSION (charset) == 1)
{
switch (XCHARSET_CHARS (charset))
{
*charset
= CHARSET_BY_LEADING_BYTE (latin_a_char_to_charset[c - 0x100]);
- *c1 = latin_a_char_to_byte1[c - 0x100];
- *c2 = latin_a_char_to_byte2[c - 0x100];
+
+ if (EQ (*charset, Vcharset_latin_iso8859_2))
+ {
+ *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_2);
+ *c2 = 0;
+ }
+ else if (EQ (*charset, Vcharset_latin_iso8859_3))
+ {
+ *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_3);
+ *c2 = 0;
+ }
+ else if (EQ (*charset, Vcharset_latin_iso8859_4))
+ {
+ *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_4);
+ *c2 = 0;
+ }
+ else if (EQ (*charset, Vcharset_latin_iso8859_9))
+ {
+ *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_9);
+ *c2 = 0;
+ }
+ else
+ {
+ *c1 = latin_a_char_to_byte1[c - 0x100];
+ *c2 = latin_a_char_to_byte2[c - 0x100];
+ }
}
else if (c < MIN_CHAR_GREEK)
{
- printf("not break up u+%x", c);
- abort ();
+ if ( (*c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_2)) )
+ {
+ *charset = Vcharset_latin_iso8859_2;
+ *c2 = 0;
+ }
+ else if ( (*c1 =
+ get_byte_from_character_table (c, ucs_to_latin_iso8859_3)) )
+ {
+ *charset = Vcharset_latin_iso8859_3;
+ *c2 = 0;
+ }
+ else if ( (*c1 =
+ get_byte_from_character_table (c, ucs_to_latin_iso8859_4)) )
+ {
+ *charset = Vcharset_latin_iso8859_4;
+ *c2 = 0;
+ }
+ else if ( (*c1 =
+ get_byte_from_character_table (c, ucs_to_latin_iso8859_9)) )
+ {
+ *charset = Vcharset_latin_iso8859_9;
+ *c2 = 0;
+ }
+ else if ( (*c1 =
+ get_byte_from_character_table (c,
+ ucs_to_latin_viscii_lower)) )
+ {
+ *charset = Vcharset_latin_viscii_lower;
+ *c2 = 0;
+ }
+ else if ( (*c1 =
+ get_byte_from_character_table (c,
+ ucs_to_latin_viscii_upper)) )
+ {
+ *charset = Vcharset_latin_viscii_upper;
+ *c2 = 0;
+ }
+ else
+ {
+ *charset = Vcharset_ucs_bmp;
+ *c1 = c >> 8;
+ *c2 = c & 0xff;
+ }
}
else if (c <= MAX_CHAR_GREEK)
{
}
else if (c < MIN_CHAR_CYRILLIC)
{
- printf("not break up u+%x", c);
- abort ();
+ *charset = Vcharset_ucs_bmp;
+ *c1 = c >> 8;
+ *c2 = c & 0xff;
}
else if (c <= MAX_CHAR_CYRILLIC)
{
}
else if (c < MIN_CHAR_HEBREW)
{
- printf("not break up u+%x", c);
- abort ();
+ *charset = Vcharset_ucs_bmp;
+ *c1 = c >> 8;
+ *c2 = c & 0xff;
}
else if (c <= MAX_CHAR_HEBREW)
{
}
else if (c < MIN_CHAR_THAI)
{
- printf("not break up u+%x", c);
- abort ();
+ *charset = Vcharset_ucs_bmp;
+ *c1 = c >> 8;
+ *c2 = c & 0xff;
}
else if (c <= MAX_CHAR_THAI)
{
}
else if (c < MIN_CHAR_HALFWIDTH_KATAKANA)
{
- printf("not break up u+%x", c);
- abort ();
+ if ( (*c1 = get_byte_from_character_table (c, ucs_to_latin_jisx0201)) )
+ {
+ *charset = Vcharset_latin_jisx0201;
+ *c2 = 0;
+ }
+ else if ( (*c1 = get_byte_from_character_table
+ (c, ucs_to_latin_viscii_lower)) )
+ {
+ *charset = Vcharset_latin_viscii_lower;
+ *c2 = 0;
+ }
+ else if ( (*c1 = get_byte_from_character_table
+ (c, ucs_to_latin_viscii_upper)) )
+ {
+ *charset = Vcharset_latin_viscii_upper;
+ *c2 = 0;
+ }
+ else
+ {
+ *charset = Vcharset_ucs_bmp;
+ *c1 = c >> 8;
+ *c2 = c & 0xff;
+ }
}
else if (c <= MAX_CHAR_HALFWIDTH_KATAKANA)
{
}
}
-#define BREAKUP_CHAR(c, charset, c1, c2) \
- breakup_char_1 (c, &(charset), &(c1), &(c2))
+#define BREAKUP_CHAR(ch, charset, b1, b2) \
+ breakup_char_1 (ch, &(charset), &(b1), &(b2))
-INLINE Lisp_Object CHAR_CHARSET (Emchar c);
+INLINE Lisp_Object CHAR_CHARSET (Emchar ch);
INLINE Lisp_Object
-CHAR_CHARSET (Emchar c)
+CHAR_CHARSET (Emchar ch)
{
Lisp_Object charset;
- int c1, c2;
+ int b1, b2;
- BREAKUP_CHAR(c, charset, c1, c2);
+ BREAKUP_CHAR(ch, charset, b1, b2);
return charset;
}
#define CHAR_LEADING_BYTE(c) (XCHARSET_LEADING_BYTE(CHAR_CHARSET(c)))
-\f
-#ifdef ENABLE_COMPOSITE_CHARS
-/************************************************************************/
-/* Composite characters */
-/************************************************************************/
-
-Emchar lookup_composite_char (Bufbyte *str, int len);
-Lisp_Object composite_char_string (Emchar ch);
-#endif /* ENABLE_COMPOSITE_CHARS */
+#define CHAR_COLUMNS(c) (CHARSET_COLUMNS(XCHARSET(CHAR_CHARSET(c))))
\f
/************************************************************************/
extern Lisp_Object Vcharset_japanese_jisx0208;
extern Lisp_Object Vcharset_japanese_jisx0212;
-Emchar Lstream_get_emchar_1 (Lstream *stream, int first_char);
-int Lstream_fput_emchar (Lstream *stream, Emchar ch);
-void Lstream_funget_emchar (Lstream *stream, Emchar ch);
-
-int copy_internal_to_external (CONST Bufbyte *internal, Bytecount len,
- unsigned char *external);
-Bytecount copy_external_to_internal (CONST unsigned char *external,
- int len, Bufbyte *internal);
-
#endif /* _XEMACS_CHAR_UCS_H */