Lines Matching +full:8 +full:- +full:ch
2 * Copyright (C) 1984-2024 Mark Nudelman
44 { "ascii", NULL, "8bcccbcc18b95.b" },
45 { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" },
46 { "iso8859", NULL, "8bcccbcc18b95.33b." },
47 { "latin3", NULL, "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
48 { "arabic", NULL, "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
49 { "greek", NULL, "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
50 { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" },
51 { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
52 { "koi8-r", NULL, "8bcccbcc18b95.b." },
53 { "KOI8-T", NULL, "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
54 { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." },
55 { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." },
56 { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." },
57 { "next", NULL, "8bcccbcc18b95.bb125.bb" },
58 { "dos", NULL, "8bcccbcc12bc5b95.b." },
59 { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." },
60 { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
61 { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
62 { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
63 { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
74 { "UTF-8", "utf-8" },
75 { "utf8", "utf-8" },
76 { "UTF8", "utf-8" },
77 { "ANSI_X3.4-1968", "ascii" },
78 { "US-ASCII", "ascii" },
80 { "ISO-8859-1", "iso8859" },
82 { "ISO-8859-15", "iso8859" },
84 { "ISO-8859-2", "iso8859" },
85 { "ISO-8859-3", "latin3" },
87 { "ISO-8859-4", "iso8859" },
89 { "ISO-8859-5", "iso8859" },
90 { "ISO-8859-6", "arabic" },
91 { "ISO-8859-7", "greek" },
93 { "ISO-8859-8", "hebrew" },
95 { "ISO-8859-9", "iso8859" },
97 { "ISO-8859-10", "iso8859" },
99 { "ISO-8859-13", "iso8859" },
101 { "ISO-8859-14", "iso8859" },
103 { "ISO-8859-16", "iso8859" },
105 { "EBCDIC-US", "ebcdic" },
106 { "IBM1047", "IBM-1047" },
107 { "KOI8-R", "koi8-r" },
108 { "KOI8-U", "koi8-r" },
109 { "GEORGIAN-PS", "georgianps" },
110 { "TCVN5712-1", "tcvn" },
112 { "windows", "windows-1252" }, /* backward compatibility */
113 { "CP1251", "windows-1251" },
114 { "CP1252", "windows-1252" },
115 { "CP1255", "windows-1255" },
141 tbl->table = (struct wchar_range *) arr->data;
142 tbl->count = (unsigned int) (arr->end / sizeof(struct wchar_range));
156 * Parse a dash-separated range of hex values.
161 range->first = lstrtoulc(s, &s, 16);
162 if (s[0] == '-')
165 range->last = lstrtoulc(s, &s, 16);
168 range->last = range->first;
215 s--;
268 case '5': case '6': case '7': case '8': case '9':
269 if (ckd_mul(&n, n, 10) || ckd_add(&n, n, s[-1] - '0'))
289 } while (--n > 0);
310 for (a = cs_aliases; a->name != NULL; a++)
312 if (strcmp(name, a->name) == 0)
314 name = a->oname;
319 for (p = charsets; p->name != NULL; p++)
321 if (strcmp(name, p->name) == 0)
323 ichardef(p->desc);
324 if (p->p_flag != NULL)
327 *(p->p_flag) = 1 + (GetConsoleOutputCP() != CP_UTF8);
329 *(p->p_flag) = 1;
433 * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
439 if ( strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL
441 if (icharset("utf-8", 1))
455 (void) icharset("utf-8", 1);
460 (void) icharset("utf-8", 1);
516 c &= 0377; /*{{type-issue}}*/
526 * and should be kept in sync with CONTROL() and IBM-1047.
543 * Return the printable form of a UTF-8 character.
545 public constant char * prutfchar(LWCHAR ch)
549 if (ch == ESC)
551 else if (ch < 128 && control_char(ch))
553 if (!control_char(ch ^ 0100))
554 SNPRINTF1(buf, sizeof(buf), "^%c", ((char) ch) ^ 0100);
556 SNPRINTF1(buf, sizeof(buf), binfmt, (char) ch);
557 } else if (is_ubin_char(ch))
559 SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch);
563 if (ch >= 0x80000000)
564 ch = 0xFFFD; /* REPLACEMENT CHARACTER */
565 put_wchar(&p, ch);
572 * Get the length of a UTF-8 character in bytes.
574 public int utf_len(char ch)
576 if ((ch & 0x80) == 0)
578 if ((ch & 0xE0) == 0xC0)
580 if ((ch & 0xF0) == 0xE0)
582 if ((ch & 0xF8) == 0xF0)
585 if ((ch & 0xFC) == 0xF8)
587 if ((ch & 0xFE) == 0xFC)
590 /* Invalid UTF-8 encoding. */
595 * Does the parameter point to the lead byte of a well-formed UTF-8 character?
617 unsigned char mask = (unsigned char) (~((1 << (8-len)) - 1));
629 * Skip bytes until a UTF-8 lead byte (11xxxxxx) or ASCII byte (0xxxxxxx) is found.
640 * Get the value of a UTF-8 character.
693 * Store a character into a UTF-8 string.
695 public void put_wchar(mutable char **pp, LWCHAR ch)
697 if (!utf_mode || ch < 0x80)
700 *(*pp)++ = (char) ch;
701 } else if (ch < 0x800)
704 *(*pp)++ = (char) (0xC0 | ((ch >> 6) & 0x1F));
705 *(*pp)++ = (char) (0x80 | (ch & 0x3F));
706 } else if (ch < 0x10000)
709 *(*pp)++ = (char) (0xE0 | ((ch >> 12) & 0x0F));
710 *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
711 *(*pp)++ = (char) (0x80 | (ch & 0x3F));
712 } else if (ch < 0x200000)
715 *(*pp)++ = (char) (0xF0 | ((ch >> 18) & 0x07));
716 *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
717 *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
718 *(*pp)++ = (char) (0x80 | (ch & 0x3F));
720 } else if (ch < 0x4000000)
723 *(*pp)++ = (char) (0xF0 | ((ch >> 24) & 0x03));
724 *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
725 *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
726 *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
727 *(*pp)++ = (char) (0x80 | (ch & 0x3F));
731 *(*pp)++ = (char) (0xF0 | ((ch >> 30) & 0x01));
732 *(*pp)++ = (char) (0x80 | ((ch >> 24) & 0x3F));
733 *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
734 *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
735 *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
736 *(*pp)++ = (char) (0x80 | (ch & 0x3F));
746 LWCHAR ch;
754 ch = (LWCHAR) (unsigned char) ((p < limit) ? *p++ : 0);
756 ch = (LWCHAR) (unsigned char) ((p > limit) ? *--p : 0);
762 ch = 0;
766 ch = get_wchar(p);
771 while (p > limit && IS_UTF8_TRAIL(p[-1]))
772 p--;
774 ch = get_wchar(--p);
776 ch = 0;
779 return ch;
785 LWCHAR ch = step_charc(&p, dir, limit);
787 return ch;
822 static lbool is_in_table(LWCHAR ch, struct wchar_range_table *table)
828 if (table->table == NULL || table->count == 0 || ch < table->table[0].first)
831 hi = table->count - 1;
835 if (ch > table->table[mid].last)
837 else if (ch < table->table[mid].first)
838 hi = mid - 1;
846 * Is a character a UTF-8 composing character?
849 public lbool is_composing_char(LWCHAR ch)
851 if (is_in_table(ch, &user_prt_table)) return FALSE;
852 return is_in_table(ch, &user_compose_table) ||
853 is_in_table(ch, &compose_table) ||
854 (bs_mode != BS_CONTROL && is_in_table(ch, &fmt_table));
858 * Should this UTF-8 character be treated as binary?
860 public lbool is_ubin_char(LWCHAR ch)
862 if (is_in_table(ch, &user_prt_table)) return FALSE;
863 return is_in_table(ch, &user_ubin_table) ||
864 is_in_table(ch, &ubin_table) ||
865 (bs_mode == BS_CONTROL && is_in_table(ch, &fmt_table));
869 * Is this a double width UTF-8 character?
871 public lbool is_wide_char(LWCHAR ch)
873 return is_in_table(ch, &user_wide_table) ||
874 is_in_table(ch, &wide_table);
878 * Is a character a UTF-8 combining character?