/* Code conversion functions.
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
+ Copyright (C) 1999,2000 MORIOKA Tomohiko
This file is part of XEmacs.
signal_simple_error ("Invalid charset conversion spec", car);
from = Fget_charset (XCAR (car));
to = Fget_charset (XCAR (XCDR (car)));
- if (XCHARSET_TYPE (from) != XCHARSET_TYPE (to))
+ if ( (XCHARSET_CHARS (from) != XCHARSET_CHARS (to)) ||
+ (XCHARSET_DIMENSION (from) != XCHARSET_DIMENSION (to)) )
signal_simple_error_2
("Attempted conversion between different charset types",
from, to);
Lisp_Object charset;
unsigned int c1, c2, s1, s2;
#ifdef UTF2000
- Lisp_Object value = charset_code_point (Vcharset_latin_jisx0201, ch);
- Lisp_Object ret = Fcar (value);
+ int code_point = charset_code_point (Vcharset_latin_jisx0201, ch);
- if (INTP (ret))
+ if (code_point >= 0)
{
charset = Vcharset_latin_jisx0201;
- c1 = XINT (ret);
+ c1 = code_point;
c2 = 0;
}
else
{
static CONST char inter94[] = "()*+";
static CONST char inter96[] = ",-./";
- unsigned int type;
+ unsigned short chars;
+ unsigned char dimension;
unsigned char final;
Lisp_Object old_charset = str->iso2022.charset[reg];
if (!CHARSETP (charset))
/* charset might be an initial nil or t. */
return;
- type = XCHARSET_TYPE (charset);
+ chars = XCHARSET_CHARS (charset);
+ dimension = XCHARSET_DIMENSION (charset);
final = XCHARSET_FINAL (charset);
if (!str->iso2022.force_charset_on_output[reg] &&
CHARSETP (old_charset) &&
- XCHARSET_TYPE (old_charset) == type &&
+ XCHARSET_CHARS (old_charset) == chars &&
+ XCHARSET_DIMENSION (old_charset) == dimension &&
XCHARSET_FINAL (old_charset) == final)
return;
}
Dynarr_add (dst, ISO_CODE_ESC);
- switch (type)
+ switch (chars)
{
- case CHARSET_TYPE_94:
- Dynarr_add (dst, inter94[reg]);
- break;
- case CHARSET_TYPE_96:
- Dynarr_add (dst, inter96[reg]);
- break;
- case CHARSET_TYPE_94X94:
- Dynarr_add (dst, '$');
- if (reg != 0
- || !(CODING_SYSTEM_ISO2022_SHORT (str->codesys))
- || final < '@'
- || final > 'B')
+ case 94:
+ if (dimension == 1)
Dynarr_add (dst, inter94[reg]);
+ else
+ {
+ Dynarr_add (dst, '$');
+ if (reg != 0
+ || !(CODING_SYSTEM_ISO2022_SHORT (str->codesys))
+ || final < '@'
+ || final > 'B')
+ Dynarr_add (dst, inter94[reg]);
+ }
break;
- case CHARSET_TYPE_96X96:
- Dynarr_add (dst, '$');
- Dynarr_add (dst, inter96[reg]);
+ case 96:
+ if (dimension == 1)
+ Dynarr_add (dst, inter96[reg]);
+ else
+ {
+ Dynarr_add (dst, '$');
+ Dynarr_add (dst, inter96[reg]);
+ }
break;
}
Dynarr_add (dst, final);
reg = -1;
for (i = 0; i < 4; i++)
{
- Lisp_Object code_point;
+ int code_point;
if ((CHARSETP (charset = str->iso2022.charset[i])
- && !EQ (code_point = charset_code_point (charset, ch), Qnil))
+ && ((code_point = charset_code_point (charset, ch)) >= 0))
||
(CHARSETP
(charset
= CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i))
- && !EQ (code_point = charset_code_point (charset, ch), Qnil)))
+ && ((code_point = charset_code_point (charset, ch)) >= 0)))
{
- Lisp_Object ret = Fcar (code_point);
-
- if (INTP (ret))
+ if (XCHARSET_DIMENSION (charset) == 1)
{
- byte1 = XINT (ret);
- ret = Fcar (Fcdr (code_point));
- if (INTP (ret))
- byte2 = XINT (ret);
- else
- byte2 = 0;
+ byte1 = code_point;
+ byte2 = 0;
}
- else
+ else /* if (XCHARSET_DIMENSION (charset) == 2) */
{
- byte1 = 0;
- byte2 = 0;
+ byte1 = code_point >> 8;
+ byte2 = code_point & 255;
}
reg = i;
break;