aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_sans_serif.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-26 17:57:59 +0100
committerMattias Andrée <m@maandree.se>2026-01-26 17:57:59 +0100
commitb48e74772cc4e6879a6d37a5c00ad6df2db1edc3 (patch)
tree4d1497bc28ff8ef8f2c4102195326dfe76b2622d /libcharconv_sans_serif.c
parentAdd flipping and turning for yijing n-grams, and add invisible (diff)
downloadcharconv-b48e74772cc4e6879a6d37a5c00ad6df2db1edc3.tar.gz
charconv-b48e74772cc4e6879a6d37a5c00ad6df2db1edc3.tar.bz2
charconv-b48e74772cc4e6879a6d37a5c00ad6df2db1edc3.tar.xz
Add enclosed
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--libcharconv_sans_serif.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/libcharconv_sans_serif.c b/libcharconv_sans_serif.c
index 152ce0c..787d14b 100644
--- a/libcharconv_sans_serif.c
+++ b/libcharconv_sans_serif.c
@@ -6,8 +6,10 @@ enum libcharconv_result
libcharconv_sans_serif(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
uint_least32_t c;
+ size_t old_slen;
*n = 0;
for (; slen--; s++) {
+ old_slen = slen;
if ('A' <= *s && *s <= 'Z') {
c = (uint_least32_t)(UINT32_C(0x1D5A0) + (unsigned)(*s - 'A'));
goto conv;
@@ -17,13 +19,54 @@ libcharconv_sans_serif(const char *s, size_t slen, size_t *n, uint_least32_t *cp
} else if ('0' <= *s && *s <= '9') {
c = (uint_least32_t)(UINT32_C(0x1D7E2) + (unsigned)(*s - '0'));
goto conv;
+ } else if ((unsigned char)s[0] == 0xE2u) {
+ if (!slen--)
+ goto indeterminate;
+ if ((unsigned char)s[1] == 0x93u) {
+ if (!slen--)
+ goto indeterminate;
+ if ((unsigned char)s[2] == 0xAAu)
+ c = (uint_least32_t)UINT32_C(0x1F10B);
+ else if ((unsigned char)s[2] == 0xBFu)
+ c = (uint_least32_t)UINT32_C(0x1F10C);
+ else
+ goto no_match;
+ goto conv3;
+ } else if ((unsigned char)s[1] == 0x91u) {
+ if (!slen--)
+ goto indeterminate;
+ if (0xA0u <= (unsigned char)s[2] && (unsigned char)s[2] <= 0xA9u)
+ c = (uint_least32_t)UINT32_C(0x2780);
+ else
+ goto no_match;
+ c += (unsigned char)s[2] - 0xA0u;
+ goto conv3;
+ } else if ((unsigned char)s[1] == 0x9Du) {
+ if (!slen--)
+ goto indeterminate;
+ if (!slen--)
+ goto indeterminate;
+ if (0xB6u <= (unsigned char)s[2] && (unsigned char)s[2] <= 0xBFu)
+ c = (uint_least32_t)UINT32_C(0x278A);
+ else
+ goto no_match;
+ c += (unsigned char)s[2] - 0xB6u;
+ goto conv3;
+ } else {
+ goto no_match;
+ }
} else {
+ no_match:
+ slen = old_slen;
*n += 1u;
}
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
+indeterminate:
+ return LIBCHARCONV_INDETERMINATE;
+
conv:
if (*n)
goto no_conv;
@@ -32,4 +75,13 @@ conv:
*n += 1u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
+
+conv3:
+ if (*n)
+ goto no_conv;
+ if (*ncp)
+ *cp = c;
+ *n += 3u;
+ *ncp = 1u;
+ return LIBCHARCONV_CONVERTED;
}