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