aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_mandaic.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-28 19:52:45 +0100
committerMattias Andrée <m@maandree.se>2026-01-28 19:52:45 +0100
commit579e91697244d5813a667bf49209ea4102bcd360 (patch)
tree2910e440fbaf968e8010b054e29c8e57b60b8935 /libcharconv_mandaic.c
parentAdd ROTATED CAPITAL Q (diff)
downloadcharconv-579e91697244d5813a667bf49209ea4102bcd360.tar.gz
charconv-579e91697244d5813a667bf49209ea4102bcd360.tar.bz2
charconv-579e91697244d5813a667bf49209ea4102bcd360.tar.xz
Misc stuff
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcharconv_mandaic.c')
-rw-r--r--libcharconv_mandaic.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/libcharconv_mandaic.c b/libcharconv_mandaic.c
new file mode 100644
index 0000000..a29ea66
--- /dev/null
+++ b/libcharconv_mandaic.c
@@ -0,0 +1,65 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ unsigned char cp_low;
+ char latin;
+} mandaic[] = {
+ {0x40, 'a'},
+ {0x41, 'b'},
+ {0x42, 'g'},
+ {0x43, 'd'},
+ {0x44, 'h'},
+ {0x45, 'u'},
+ {0x45, 'w'},
+ {0x46, 'z'},
+ {0x47, 'H'},
+ {0x48, 'T'},
+ {0x49, 'j'},
+ {0x49, 'j'},
+ {0x4A, 'k'},
+ {0x4B, 'l'},
+ {0x4C, 'm'},
+ {0x4D, 'n'},
+ {0x4E, 's'},
+ {0x4F, 'e'},
+ {0x50, 'p'},
+ {0x51, 'Z'},
+ {0x52, 'q'},
+ {0x53, 'r'},
+ {0x54, 'S'},
+ {0x55, 't'},
+ {0x56, 'D'},
+ {0x57, 'K'},
+ {0x58, 'o'},
+ {0x59, '\''},
+ {0x5A, '*'},
+ {0x5B, ':'},
+ {0x5E, '.'}
+};
+
+
+enum libcharconv_result
+libcharconv_mandaic(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
+{
+ size_t i;
+ *n = 0;
+ for (; slen--; s++) {
+ for (i = 0u; i < sizeof(mandaic) / sizeof(*mandaic); i++)
+ if (*s == mandaic[i].latin)
+ goto conv;
+ *n += 1u;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ *n += 1u;
+ if (*ncp)
+ *cp = (uint_least32_t)(UINT32_C(0x0800) | mandaic[i].cp_low);
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}