aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_latin.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcharconv_latin.c')
-rw-r--r--libcharconv_latin.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index 25aae91..d3c1817 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -9,6 +9,7 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
uint_least32_t c;
char c1, c2, c3, c4;
size_t clen;
+ unsigned num;
*n = 0;
while (slen) {
@@ -273,6 +274,31 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
c3 = '.';
goto conv3;
+ } else if (UINT32_C(0xFE00) <= c && c <= UINT32_C(0xFE0F)) {
+ /* variation selectors */
+ num = (unsigned)(c - UINT32_C(0xFE00)) + 1u;
+ if (num < 10) {
+ c1 = (char)('0' + num);
+ goto conv1;
+ } else {
+ c1 = (char)('0' + num / 10);
+ c2 = (char)('0' + num % 10);
+ goto conv2;
+ }
+ } else if (UINT32_C(0xE0100) <= c && c <= UINT32_C(0xE01EF)) {
+ /* variation selectors */
+ num = (unsigned)(c - UINT32_C(0xE0100)) + 17u;
+ if (num < 100) {
+ c1 = (char)('0' + num / 10);
+ c2 = (char)('0' + num % 10);
+ goto conv2;
+ } else {
+ c1 = (char)('0' + num / 100);
+ c2 = (char)('0' + num / 10 % 10);
+ c3 = (char)('0' + num % 10);
+ goto conv3;
+ }
+
} else {
switch (c) {
/* shogi */
@@ -413,6 +439,8 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
no_conv:
return LIBCHARCONV_NO_CONVERT;
+conv1:
+ c = (uint_least32_t)c1;
conv:
if (*n)
goto no_conv;