summaryrefslogtreecommitdiff
path: root/lscp.c
diff options
context:
space:
mode:
authorJens Schweikhardt <schweikh@schweikhardt.net>2025-08-18 23:25:41 +0200
committerJens Schweikhardt <schweikh@schweikhardt.net>2025-08-18 23:25:41 +0200
commit88ad7de6e6ba2c2af1d58ebb556cc62442660564 (patch)
tree4534855b0821d5191b85c4d7cf6c23fa713849d4 /lscp.c
parent3a25bd58be72b77b677e41ae5ef25005e168aa1f (diff)
First cut.
Diffstat (limited to 'lscp.c')
-rw-r--r--lscp.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/lscp.c b/lscp.c
new file mode 100644
index 0000000..fdc9857
--- /dev/null
+++ b/lscp.c
@@ -0,0 +1,58 @@
+/*
+ * NAME
+ * lscp - list a range of codepoints with width and name
+ *
+ * EXAMPLE USAGE
+ * $ ./lscp 0x2a00 0x2a10
+ * U+2a00 1 a ⨀ b N-ARY CIRCLED DOT OPERATOR
+ * U+2a01 1 a ⨁ b N-ARY CIRCLED PLUS OPERATOR
+ * U+2a02 1 a ⨂ b N-ARY CIRCLED TIMES OPERATOR
+ * U+2a03 1 a ⨃ b N-ARY UNION OPERATOR WITH DOT
+ * U+2a04 1 a ⨄ b N-ARY UNION OPERATOR WITH PLUS
+ * U+2a05 1 a ⨅ b N-ARY SQUARE INTERSECTION OPERATOR
+ * U+2a06 1 a ⨆ b N-ARY SQUARE UNION OPERATOR
+ * U+2a07 1 a ⨇ b TWO LOGICAL AND OPERATOR
+ * U+2a08 1 a ⨈ b TWO LOGICAL OR OPERATOR
+ * U+2a09 1 a ⨉ b N-ARY TIMES OPERATOR
+ * U+2a0a 1 a ⨊ b MODULO TWO SUM
+ * U+2a0b 1 a ⨋ b SUMMATION WITH INTEGRAL
+ * U+2a0c 1 a ⨌ b QUADRUPLE INTEGRAL OPERATOR
+ * U+2a0d 1 a ⨍ b FINITE PART INTEGRAL
+ * U+2a0e 1 a ⨎ b INTEGRAL WITH DOUBLE STROKE
+ * U+2a0f 1 a ⨏ b INTEGRAL AVERAGE WITH SLAS
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <wchar.h>
+#include <errno.h>
+
+/* FreeBSD: devel/libunistring */
+#include <uniname.h>
+
+int main(int aArgc, char **aArgv) {
+ if (!setlocale(LC_CTYPE, "")) {
+ fprintf(stderr, "Can't set the locale. Check LANG, LC_CTYPE, LC_ALL.\n");
+ exit(EXIT_FAILURE);
+ }
+ if (aArgc != 3) {
+ fprintf(stderr, "usage: %s start end\n", aArgv[0]);
+ exit(EXIT_FAILURE);
+ }
+ unsigned long start, end;
+ errno = 0;
+ start = strtoul(aArgv[1], NULL, 0);
+ end = strtoul(aArgv[2], NULL, 0);
+ if (errno != 0) {
+ fprintf(stderr, "could not convert arguments to integers\n");
+ exit(EXIT_FAILURE);
+ }
+ for (unsigned long i = start; i < end; ++i) {
+ char name[UNINAME_MAX + 1];
+ const char *const p = unicode_character_name((ucs4_t) i, name);
+ printf("U+%04x %2d a %lc b %s\n", (unsigned int) i, wcwidth(i), (wint_t) i, p ? p : "<no name>");
+ }
+ return EXIT_SUCCESS;
+}
+
+/* vim: set tabstop=4 shiftwidth=4 expandtab fileformat=unix: */