aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--convert-to-sora-sompeng.c4
-rw-r--r--libcharconv.h5
-rw-r--r--libcharconv_latin.c9
-rw-r--r--libcharconv_sora_sompeng.c69
5 files changed, 91 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 097e702..743603d 100644
--- a/Makefile
+++ b/Makefile
@@ -66,7 +66,8 @@ BIN =\
convert-to-joined\
convert-to-mirrored\
convert-to-turned\
- convert-to-transposed
+ convert-to-transposed\
+ convert-to-sora-sompeng
LIBOBJ =\
libcharconv_decode_utf8_.o\
@@ -121,7 +122,8 @@ LIBOBJ =\
libcharconv_joined.o\
libcharconv_mirrored.o\
libcharconv_turned.o\
- libcharconv_transposed.o
+ libcharconv_transposed.o\
+ libcharconv_sora_sompeng.o
LOBJ = $(LIBOBJ:.o=.lo)
diff --git a/convert-to-sora-sompeng.c b/convert-to-sora-sompeng.c
new file mode 100644
index 0000000..2dcbf3b
--- /dev/null
+++ b/convert-to-sora-sompeng.c
@@ -0,0 +1,4 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+SIMPLE(libcharconv_sora_sompeng)
diff --git a/libcharconv.h b/libcharconv.h
index a3f6b21..7588c41 100644
--- a/libcharconv.h
+++ b/libcharconv.h
@@ -358,6 +358,11 @@ LIBCHARCONV_FUNC_(libcharconv_turned);
*/
LIBCHARCONV_FUNC_(libcharconv_transposed);
+/**
+ * Convert from Latin to Sora Sompeng
+ */
+LIBCHARCONV_FUNC_(libcharconv_sora_sompeng);
+
#undef LIBCHARCONV_FUNC_
#endif
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index e984f51..dabad30 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -434,6 +434,15 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
c1 = (i & 32u) ? '2' : '1';
goto conv6;
+ } else if (UINT32_C(0x110D0) <= c && c <= UINT32_C(0x110E8)) {
+ /* sora sompeng */
+ c = (uint_least32_t)"stbcdgmGlnvpyrhkjYaEiuoeM"[c - UINT32_C(0x110D0)];
+ goto conv;
+ } else if (UINT32_C(0x110F0) <= c && c <= UINT32_C(0x110F9)) {
+ /* sora sompeng */
+ c -= (uint_least32_t)UINT32_C(0x110F0) - (uint_least32_t)'0';
+ goto conv;
+
} else {
use_switch:
switch (c) {
diff --git a/libcharconv_sora_sompeng.c b/libcharconv_sora_sompeng.c
new file mode 100644
index 0000000..6ced61d
--- /dev/null
+++ b/libcharconv_sora_sompeng.c
@@ -0,0 +1,69 @@
+/* See LICENSE file for copyright and license details. */
+#include "lib-common.h"
+
+
+static struct {
+ unsigned char cp_low;
+ char latin;
+} sora_sompeng[] = {
+ {0xE2, 'a'},
+ {0xD2, 'b'},
+ {0xD3, 'c'},
+ {0xD4, 'd'},
+ {0xE7, 'e'},
+ {0xE3, 'E'},
+ {0xD5, 'g'},
+ {0xD7, 'G'},
+ {0xDE, 'h'},
+ {0xE4, 'i'},
+ {0xE0, 'j'},
+ {0xDF, 'k'},
+ {0xD8, 'l'},
+ {0xD9, 'n'},
+ {0xD6, 'm'},
+ {0xE8, 'M'},
+ {0xE6, 'o'},
+ {0xDB, 'p'},
+ {0xDD, 'r'},
+ {0xD0, 's'},
+ {0xD1, 't'},
+ {0xE5, 'u'},
+ {0xDA, 'v'},
+ {0xDC, 'y'},
+ {0xE1, 'Y'},
+ {0xF0, '0'},
+ {0xF1, '1'},
+ {0xF2, '2'},
+ {0xF3, '3'},
+ {0xF4, '4'},
+ {0xF5, '5'},
+ {0xF6, '6'},
+ {0xF7, '7'},
+ {0xF8, '8'},
+ {0xF9, '9'}
+};
+
+
+enum libcharconv_result
+libcharconv_sora_sompeng(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(sora_sompeng) / sizeof(*sora_sompeng); i++)
+ if (*s == sora_sompeng[i].latin)
+ goto conv;
+ *n += 1u;
+ }
+no_conv:
+ return LIBCHARCONV_NO_CONVERT;
+
+conv:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = (uint_least32_t)(UINT32_C(0x11000) | sora_sompeng[i].cp_low);
+ *n += 1u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
+}