aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-25 17:23:41 +0100
committerMattias Andrée <m@maandree.se>2026-01-25 17:23:41 +0100
commit2707fbda25ae9554280111ea2f5999e2feac4b20 (patch)
treefa85500503c700e78d6d27c1cfa5d6f8312a409d
parentAdd sora sompeng (diff)
downloadcharconv-2707fbda25ae9554280111ea2f5999e2feac4b20.tar.gz
charconv-2707fbda25ae9554280111ea2f5999e2feac4b20.tar.bz2
charconv-2707fbda25ae9554280111ea2f5999e2feac4b20.tar.xz
Add tally marks and ideographic tally marks
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Makefile8
-rw-r--r--convert-to-ideographic-tally-marks.c4
-rw-r--r--convert-to-tally-marks.c4
-rw-r--r--libcharconv.h10
-rw-r--r--libcharconv_ideographic_tally_marks.c33
-rw-r--r--libcharconv_latin.c11
-rw-r--r--libcharconv_tally_marks.c30
7 files changed, 98 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 743603d..d69be0a 100644
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,9 @@ BIN =\
convert-to-mirrored\
convert-to-turned\
convert-to-transposed\
- convert-to-sora-sompeng
+ convert-to-sora-sompeng\
+ convert-to-tally-marks\
+ convert-to-ideographic-tally-marks
LIBOBJ =\
libcharconv_decode_utf8_.o\
@@ -123,7 +125,9 @@ LIBOBJ =\
libcharconv_mirrored.o\
libcharconv_turned.o\
libcharconv_transposed.o\
- libcharconv_sora_sompeng.o
+ libcharconv_sora_sompeng.o\
+ libcharconv_tally_marks.o\
+ libcharconv_ideographic_tally_marks.o
LOBJ = $(LIBOBJ:.o=.lo)
diff --git a/convert-to-ideographic-tally-marks.c b/convert-to-ideographic-tally-marks.c
new file mode 100644
index 0000000..c35411b
--- /dev/null
+++ b/convert-to-ideographic-tally-marks.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_ideographic_tally_marks)
diff --git a/convert-to-tally-marks.c b/convert-to-tally-marks.c
new file mode 100644
index 0000000..717589c
--- /dev/null
+++ b/convert-to-tally-marks.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_tally_marks)
diff --git a/libcharconv.h b/libcharconv.h
index 7588c41..5b032ee 100644
--- a/libcharconv.h
+++ b/libcharconv.h
@@ -363,6 +363,16 @@ LIBCHARCONV_FUNC_(libcharconv_transposed);
*/
LIBCHARCONV_FUNC_(libcharconv_sora_sompeng);
+/**
+ * Convert '1' and '5' to TALLY MARKs
+ */
+LIBCHARCONV_FUNC_(libcharconv_tally_marks);
+
+/**
+ * Convert '1' through '5' to IDEOGRAPHIC TALLY MARKs
+ */
+LIBCHARCONV_FUNC_(libcharconv_ideographic_tally_marks);
+
#undef LIBCHARCONV_FUNC_
#endif
diff --git a/libcharconv_ideographic_tally_marks.c b/libcharconv_ideographic_tally_marks.c
new file mode 100644
index 0000000..508c3cc
--- /dev/null
+++ b/libcharconv_ideographic_tally_marks.c
@@ -0,0 +1,33 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+enum libcharconv_result
+libcharconv_ideographic_tally_marks(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ *n = 0;
+ for (; slen--; s++) {
+ switch (*s) {
+ case '1': c = UINT32_C(0x13D72); goto conv;
+ case '2': c = UINT32_C(0x13D73); goto conv;
+ case '3': c = UINT32_C(0x13D74); goto conv;
+ case '4': c = UINT32_C(0x13D75); goto conv;
+ case '5': c = UINT32_C(0x13D76); goto conv;
+ default:
+ *n += 1u;
+ break;
+ }
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index dabad30..1961b18 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -658,6 +658,17 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
case UINT32_C(0x2E35): c = UINT32_C(0x003B); goto conv;
case UINT32_C(0x1F12F): c1 = '('; c2 = 'C'; c3 = ')'; goto conv3;
+ /* tally marks */
+ case UINT32_C(0x13D77): c1 = '1'; goto conv1;
+ case UINT32_C(0x13D78): c1 = '5'; goto conv1;
+
+ /* ideographic tally marks */
+ case UINT32_C(0x13D72): c1 = '1'; goto conv1;
+ case UINT32_C(0x13D73): c1 = '2'; goto conv1;
+ case UINT32_C(0x13D74): c1 = '3'; goto conv1;
+ case UINT32_C(0x13D75): c1 = '4'; goto conv1;
+ case UINT32_C(0x13D76): c1 = '5'; goto conv1;
+
default:
no_match:
*n += clen;
diff --git a/libcharconv_tally_marks.c b/libcharconv_tally_marks.c
new file mode 100644
index 0000000..e94f48d
--- /dev/null
+++ b/libcharconv_tally_marks.c
@@ -0,0 +1,30 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+enum libcharconv_result
+libcharconv_tally_marks(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ uint_least32_t c;
+ *n = 0;
+ for (; slen--; s++) {
+ switch (*s) {
+ case '1': c = UINT32_C(0x13D77); goto conv;
+ case '5': c = UINT32_C(0x13D78); goto conv;
+ default:
+ *n += 1u;
+ break;
+ }
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}