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