Commit | Line | Data |
---|---|---|
8d138742 CE |
1 | /* |
2 | ** Copyright 2000-2003 Double Precision, Inc. | |
3 | ** See COPYING for distribution information. | |
4 | ** | |
8d138742 CE |
5 | */ |
6 | ||
7 | #include "unicode_config.h" | |
8 | #include "unicode.h" | |
9 | ||
10 | extern const unsigned unicode_case_hash; | |
11 | extern const unicode_char unicode_case_tab[][4]; | |
12 | extern const unsigned unicode_case_offset[]; | |
13 | ||
14 | static unsigned find_case(unicode_char c) | |
15 | { | |
16 | unsigned idx= c % unicode_case_hash; | |
17 | ||
18 | unsigned i=unicode_case_offset[idx]; | |
19 | ||
20 | unicode_char uc; | |
21 | ||
22 | --i; | |
23 | ||
24 | do | |
25 | { | |
26 | uc=unicode_case_tab[++i][0]; | |
27 | if (uc == c) | |
28 | return (i); | |
29 | } while ( (uc % unicode_case_hash) == idx); | |
30 | ||
31 | return (0); | |
32 | } | |
33 | ||
34 | unicode_char unicode_uc(unicode_char c) | |
35 | { | |
36 | unsigned i=find_case(c); | |
37 | ||
38 | return (unicode_case_tab[i][0] != c ? c:unicode_case_tab[i][1]); | |
39 | } | |
40 | ||
41 | unicode_char unicode_lc(unicode_char c) | |
42 | { | |
43 | unsigned i=find_case(c); | |
44 | ||
45 | return (unicode_case_tab[i][0] != c ? c:unicode_case_tab[i][2]); | |
46 | } | |
47 | ||
48 | unicode_char unicode_tc(unicode_char c) | |
49 | { | |
b0322a85 CE |
50 | unsigned i; |
51 | unicode_char oc=c; | |
52 | ||
53 | c=unicode_lc(c); | |
54 | i=find_case(c); | |
8d138742 | 55 | |
b0322a85 | 56 | return (unicode_case_tab[i][0] != c ? oc:unicode_case_tab[i][3]); |
8d138742 | 57 | } |