1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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;
}
|