/* 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; }