non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c)
{
Bufbyte *p;
+#ifndef UTF2000
Bufbyte lb;
int c1, c2;
Lisp_Object charset;
+#endif
p = str;
+#ifdef UTF2000
+ if ( c <= 0x7f )
+ {
+ *p++ = c;
+ }
+ else if ( c <= 0x7ff )
+ {
+ *p++ = (c >> 6) | 0xc0;
+ *p++ = (c & 0x3f) | 0x80;
+ }
+ else if ( c <= 0xffff )
+ {
+ *p++ = (c >> 12) | 0xe0;
+ *p++ = ((c >> 6) & 0x3f) | 0x80;
+ *p++ = (c & 0x3f) | 0x80;
+ }
+ else if ( c <= 0x1fffff )
+ {
+ *p++ = (c >> 18) | 0xf0;
+ *p++ = ((c >> 12) & 0x3f) | 0x80;
+ *p++ = ((c >> 6) & 0x3f) | 0x80;
+ *p++ = (c & 0x3f) | 0x80;
+ }
+ else if ( c <= 0x3ffffff )
+ {
+ *p++ = (c >> 24) | 0xf8;
+ *p++ = ((c >> 18) & 0x3f) | 0x80;
+ *p++ = ((c >> 12) & 0x3f) | 0x80;
+ *p++ = ((c >> 6) & 0x3f) | 0x80;
+ *p++ = (c & 0x3f) | 0x80;
+ }
+ else
+ {
+ *p++ = (c >> 30) | 0xfc;
+ *p++ = ((c >> 24) & 0x3f) | 0x80;
+ *p++ = ((c >> 18) & 0x3f) | 0x80;
+ *p++ = ((c >> 12) & 0x3f) | 0x80;
+ *p++ = ((c >> 6) & 0x3f) | 0x80;
+ *p++ = (c & 0x3f) | 0x80;
+ }
+#else
BREAKUP_CHAR (c, charset, c1, c2);
lb = CHAR_LEADING_BYTE (c);
if (LEADING_BYTE_PRIVATE_P (lb))
*p++ = c1 | 0x80;
if (c2)
*p++ = c2 | 0x80;
-
+#endif
return (p - str);
}
Emchar
non_ascii_charptr_emchar (CONST Bufbyte *str)
{
+#ifdef UTF2000
+ Bufbyte b;
+ Emchar ch;
+ int len;
+
+ b = *str++;
+ if ( b >= 0xfc )
+ {
+ ch = (b & 0x01);
+ len = 5;
+ }
+ else if ( b >= 0xf8 )
+ {
+ ch = b & 0x03;
+ len = 4;
+ }
+ else if ( b >= 0xf0 )
+ {
+ ch = b & 0x07;
+ len = 3;
+ }
+ else if ( b >= 0xe0 )
+ {
+ ch = b & 0x0f;
+ len = 2;
+ }
+ else if ( b >= 0xc0 )
+ {
+ ch = b & 0x1f;
+ len = 1;
+ }
+ else
+ {
+ ch = b;
+ len = 0;
+ }
+ for( ; len > 0; len-- )
+ {
+ b = *str++;
+ ch = ( ch << 6 ) | ( b & 0x3f );
+ }
+ return ch;
+#else
Bufbyte i0 = *str, i1, i2 = 0;
Lisp_Object charset;
i2 = *++str & 0x7F;
return MAKE_CHAR (charset, i1, i2);
+#endif
}
/* Return whether CH is a valid Emchar, assuming it's non-ASCII.
Do not call this directly. Use the macro valid_char_p() instead. */
+#ifndef UTF2000
int
non_ascii_valid_char_p (Emchar ch)
{
return (XCHARSET_CHARS (charset) == 96);
}
}
+#endif
\f
/************************************************************************/
switch (REP_BYTES_BY_FIRST_BYTE (*strptr))
{
/* Notice fallthrough. */
+#ifdef UTF2000
+ case 6: *++strptr = *ptr++;
+ case 5: *++strptr = *ptr++;
+#endif
case 4: *++strptr = *ptr++;
case 3: *++strptr = *ptr++;
case 2: *++strptr = *ptr;
switch (REP_BYTES_BY_FIRST_BYTE (ch))
{
/* Notice fallthrough. */
+#ifdef UTF2000
+ case 6:
+ ch = Lstream_getc (stream);
+ assert (ch >= 0);
+ *++strptr = (Bufbyte) ch;
+ case 5:
+ ch = Lstream_getc (stream);
+ assert (ch >= 0);
+ *++strptr = (Bufbyte) ch;
+#endif
case 4:
ch = Lstream_getc (stream);
assert (ch >= 0);
defsymbol (&Qcomposite, "composite");
- Vutf_2000_version = build_string("0.1");
+#ifdef UTF2000
+ Vutf_2000_version = build_string("0.2");
DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /*
Version number of UTF-2000.
*/ );
+#endif
leading_code_private_11 = PRE_LEADING_BYTE_PRIVATE_1;
DEFVAR_INT ("leading-code-private-11", &leading_code_private_11 /*