3 static const unsigned char tab[];
5 static const unsigned char rulebases[512];
6 static const int rules[];
8 static const unsigned char exceptions[][2];
12 static int casemap(unsigned c, int dir)
14 unsigned b, x, y, v, rt, xb, xn;
17 if (c >= 0x20000) return c;
24 /* lookup entry in two-level base-6 table */
26 static const int mt[] = { 2048, 342, 57 };
29 /* use the bit vector out of the tables as an index into
30 * a block-specific set of rules and decode the rule into
31 * a type and a case-mapping delta. */
32 r = rules[rulebases[b]+v];
36 /* rules 0/1 are simple lower/upper case with a delta.
37 * apply according to desired mapping direction. */
38 if (rt < 2) return c0 + (rd & -(rt^dir));
40 /* binary search. endpoints of the binary search for
41 * this block are stored in the rule delta field. */
43 xb = (unsigned)rd >> 8;
45 unsigned try = exceptions[xb+xn/2][0];
47 r = rules[exceptions[xb+xn/2][1]];
50 if (rt < 2) return c0 + (rd & -(rt^dir));
51 /* Hard-coded for the four exceptional titlecase */
52 return c0 + (dir ? -1 : 1);
63 wint_t towlower(wint_t wc)
65 return casemap(wc, 0);
68 wint_t towupper(wint_t wc)
70 return casemap(wc, 1);
73 wint_t __towupper_l(wint_t c, locale_t l)
78 wint_t __towlower_l(wint_t c, locale_t l)
83 weak_alias(__towupper_l, towupper_l);
84 weak_alias(__towlower_l, towlower_l);