From 35ad65b0276cfca80aea68122122b78f8f3777c2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 25 Jan 2026 17:00:55 +0100 Subject: Add sora sompeng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcharconv_sora_sompeng.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 libcharconv_sora_sompeng.c (limited to 'libcharconv_sora_sompeng.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; +} -- cgit v1.2.3-70-g09d2