diff options
Diffstat (limited to '')
| -rw-r--r-- | libcharconv_lycian.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libcharconv_lycian.c b/libcharconv_lycian.c new file mode 100644 index 0000000..7998ecb --- /dev/null +++ b/libcharconv_lycian.c @@ -0,0 +1,63 @@ +/* See LICENSE file for copyright and license details. */ +#include "lib-common.h" + + +static struct { + unsigned char cp_low; + char latin; +} lycian[] = { + {0x80, 'a'}, + {0x82, 'b'}, + {0x85, 'd'}, + {0x81, 'e'}, + {0x84, 'g'}, + {0x9B, 'h'}, + {0x86, 'i'}, + {0x8A, 'j'}, + {0x8B, 'k'}, + {0x8D, 'l'}, + {0x8E, 'm'}, + {0x8F, 'n'}, + {0x93, 'p'}, + {0x8C, 'q'}, + {0x95, 'r'}, + {0x96, 's'}, + {0x97, 't'}, + {0x92, 'u'}, + {0x87, 'w'}, + {0x9C, 'x'}, + {0x88, 'z'}, + {0x99, 'A'}, + {0x83, 'B'}, + {0x89, 'D'}, + {0x9A, 'E'}, + {0x94, 'K'}, + {0x90, 'M'}, + {0x91, 'N'}, + {0x98, 'T'} +}; + + +enum libcharconv_result +libcharconv_lycian(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(lycian) / sizeof(*lycian); i++) + if (*s == lycian[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(0x10200) | lycian[i].cp_low); + *n += 1u; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; +} |
