diff options
| author | Mattias Andrée <m@maandree.se> | 2026-01-28 19:52:45 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-01-28 19:52:45 +0100 |
| commit | 579e91697244d5813a667bf49209ea4102bcd360 (patch) | |
| tree | 2910e440fbaf968e8010b054e29c8e57b60b8935 /libcharconv_gothic.c | |
| parent | Add ROTATED CAPITAL Q (diff) | |
| download | charconv-579e91697244d5813a667bf49209ea4102bcd360.tar.gz charconv-579e91697244d5813a667bf49209ea4102bcd360.tar.bz2 charconv-579e91697244d5813a667bf49209ea4102bcd360.tar.xz | |
Misc stuff
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcharconv_gothic.c')
| -rw-r--r-- | libcharconv_gothic.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libcharconv_gothic.c b/libcharconv_gothic.c new file mode 100644 index 0000000..61ec9a9 --- /dev/null +++ b/libcharconv_gothic.c @@ -0,0 +1,91 @@ +/* See LICENSE file for copyright and license details. */ +#include "lib-common.h" + + +static struct { + unsigned char cp_low; + char latin; +} gothic[] = { + {0x30, 'a'}, + {0x31, 'b'}, + {0x32, 'g'}, + {0x32, 'G'}, + {0x33, 'd'}, + {0x33, 'D'}, + {0x34, 'e'}, + {0x35, 'q'}, + {0x36, 'z'}, + {0x37, 'h'}, + {0x38, 'T'}, + {0x39, 'i'}, + {0x3A, 'k'}, + {0x3B, 'l'}, + {0x3C, 'm'}, + {0x3D, 'n'}, + {0x3E, 'j'}, + {0x3F, 'u'}, + {0x40, 'p'}, + {0x42, 'r'}, + {0x43, 's'}, + {0x44, 't'}, + {0x45, 'w'}, + {0x45, 'y'}, + {0x46, 'f'}, + {0x47, 'x'}, + {0x48, 'v'}, + {0x48, 'W'}, + {0x49, 'o'} +}; + + +enum libcharconv_result +libcharconv_gothic(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp) +{ + uint_least32_t c; + size_t i; + *n = 0; + for (; slen--; s++) { + if ('1' <= *s && *s <= '9') { + if (*n) + goto no_conv; + c = UINT32_C(0x10330) + (uint_least32_t)(*s - '1'); + *n = 1u; + if (slen == 0u) + goto convn_if_end; + if (s[1] != '0') + goto convn; + c += 9u; + *n += 1u; + if (slen == 1u) + goto convn_if_end; + if (s[2] == '0') { + c += 9u; + *n += 1u; + } + goto convn; + } else { + for (i = 0u; i < sizeof(gothic) / sizeof(*gothic); i++) + if (*s == gothic[i].latin) + goto conv; + *n += 1u; + } + } +no_conv: + return LIBCHARCONV_NO_CONVERT; + +conv: + if (*n) + goto no_conv; + *n += 1u; + c = (uint_least32_t)(UINT32_C(0x10300) | gothic[i].cp_low); +convn: + if (*ncp) + *cp = c; + *ncp = 1u; + return LIBCHARCONV_CONVERTED; +convn_if_end: + if (*ncp) + *cp = c; + *ncp = 1u; + return LIBCHARCONV_CONVERT_IF_END; +} |
