2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
22 #include "widechar_width.h"
24 #define class_combining -1
29 static int char_class(int c
)
31 int w
= widechar_wcwidth(c
);
33 case 1: return class_one
;
34 case 2: return class_two
;
35 case widechar_nonprint
: return class_zero
;
36 case widechar_combining
: return class_combining
;
37 case widechar_ambiguous
: return class_one
;
38 case widechar_private_use
: return class_one
;
39 case widechar_unassigned
: return class_one
;
40 case widechar_widened_in_9
: return class_two
;
41 case widechar_non_character
: return class_zero
;
52 printf(" * No-copyright\n");
53 printf(" * A table of numbers, generated by a script, is supposedly not copyrightable.\n");
56 printf("private unit uni_table;\n");
58 printf("const uni_table~cache : list(char);\n");
60 printf("implementation\n");
62 printf("const uni_table~cache : list(char) := list(char).[\n");
64 for (i
= 0; i
< 0x110000; i
++) {
65 int cls
= char_class(i
);
66 if (cls
!= last_cls
) {
67 printf("\t#%x, %d,\n", i
, cls
);
71 if (last_cls
!= class_zero
)
72 printf("\t#%x, %d,\n", i
, class_zero
);