From c90e1424c07a2f220ae8b902496cef1c1c371fff Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 26 Jan 2026 19:14:21 +0100 Subject: Add dentistry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcharconv_dentistry.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 libcharconv_dentistry.c (limited to 'libcharconv_dentistry.c') diff --git a/libcharconv_dentistry.c b/libcharconv_dentistry.c new file mode 100644 index 0000000..e3f463e --- /dev/null +++ b/libcharconv_dentistry.c @@ -0,0 +1,61 @@ +/* See LICENSE file for copyright and license details. */ +#include "lib-common.h" + + +enum libcharconv_result +libcharconv_dentistry(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp) +{ + uint_least32_t c; + *n = 0; + for (; slen--; s++) { + switch (*s) { + case 'o': + case 'O': c = UINT32_C(0x23C0); goto conv; + case 'a': + case 'A': c = UINT32_C(0x23C3); goto conv; + case '~': c = UINT32_C(0x23C6); goto conv; + case 'l': c = UINT32_C(0x23BF); goto conv; + case 'j': c = UINT32_C(0x23CC); goto conv; + case 't': c = UINT32_C(0x23CA); goto conv; + case 'L': c = UINT32_C(0x23BE); goto conv; + case 'J': c = UINT32_C(0x23CB); goto conv; + case 'T': c = UINT32_C(0x23C9); goto conv; + case '-': + case '_': + if (!slen) + return LIBCHARCONV_INDETERMINATE; + if (s[1] != 'A' && s[1] != 'O' && s[1] != '~') + if (s[1] != 'a' && s[1] != 'o') + goto no_match; + c = (s[1] == 'A' || s[1] == 'a') ? UINT32_C(0x23C1) : + (s[1] == 'O' || s[1] == 'o') ? UINT32_C(0x23C4) : UINT32_C(0x23C7); + if (s[0] == '_') + c += 1u; + goto conv2; + default: + no_match: + *n += 1u; + break; + } + } +no_conv: + return LIBCHARCONV_NO_CONVERT; + +conv: + if (*n) + goto no_conv; + if (*ncp) + *cp = c; + *n += 1u; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; + +conv2: + if (*n) + goto no_conv; + if (*ncp) + *cp = c; + *n += 2u; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; +} -- cgit v1.2.3-70-g09d2