Panda3D
unicodeLatinMap.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file unicodeLatinMap.h
10  * @author drose
11  * @date 2003-02-01
12  */
13 
14 #ifndef UNICODELATINMAP_H
15 #define UNICODELATINMAP_H
16 
17 #include "dtoolbase.h"
18 #include "pmap.h"
19 
20 /**
21  * This class mainly serves as a container for a largish table of the subset
22  * of the Unicode character set that corresponds to the Latin alphabet, with
23  * its various accent marks and so on. Specifically, this table indicates how
24  * to map between the Unicode accented character and the corresponding ASCII
25  * equivalent without the accent mark; as well as how to switch case from
26  * upper to lower while retaining the Unicode accent marks.
27  */
28 class EXPCL_DTOOL_DTOOLUTIL UnicodeLatinMap {
29 public:
30  enum AccentType {
31  AT_none,
32  AT_acute,
33  AT_acute_and_dot_above,
34  AT_breve,
35  AT_breve_and_acute,
36  AT_breve_and_dot_below,
37  AT_breve_and_grave,
38  AT_breve_and_hook_above,
39  AT_breve_and_tilde,
40  AT_breve_below,
41  AT_caron,
42  AT_caron_and_dot_above,
43  AT_cedilla,
44  AT_cedilla_and_acute,
45  AT_cedilla_and_breve,
46  AT_circumflex,
47  AT_circumflex_and_acute,
48  AT_circumflex_and_dot_below,
49  AT_circumflex_and_grave,
50  AT_circumflex_and_hook_above,
51  AT_circumflex_and_tilde,
52  AT_circumflex_below,
53  AT_comma_below,
54  AT_curl,
55  AT_diaeresis,
56  AT_diaeresis_and_acute,
57  AT_diaeresis_and_caron,
58  AT_diaeresis_and_grave,
59  AT_diaeresis_and_macron,
60  AT_diaeresis_below,
61  AT_dot_above,
62  AT_dot_above_and_macron,
63  AT_dot_below,
64  AT_dot_below_and_dot_above,
65  AT_dot_below_and_macron,
66  AT_double_acute,
67  AT_double_grave,
68  AT_grave,
69  AT_hook,
70  AT_hook_above,
71  AT_horn,
72  AT_horn_and_acute,
73  AT_horn_and_dot_below,
74  AT_horn_and_grave,
75  AT_horn_and_hook_above,
76  AT_horn_and_tilde,
77  AT_inverted_breve,
78  AT_line_below,
79  AT_macron,
80  AT_macron_and_acute,
81  AT_macron_and_diaeresis,
82  AT_macron_and_grave,
83  AT_ogonek,
84  AT_ogonek_and_macron,
85  AT_ring_above,
86  AT_ring_above_and_acute,
87  AT_ring_below,
88  AT_stroke,
89  AT_stroke_and_acute,
90  AT_stroke_and_hook,
91  AT_tilde,
92  AT_tilde_and_acute,
93  AT_tilde_and_diaeresis,
94  AT_tilde_and_macron,
95  AT_tilde_below,
96  AT_topbar,
97  };
98 
99  enum AdditionalFlags {
100  AF_ligature = 0x0001,
101  AF_turned = 0x0002,
102  AF_reversed = 0x0004,
103  AF_smallcap = 0x0008,
104  AF_dotless = 0x0010,
105  };
106 
107  enum CharType {
108  CT_upper,
109  CT_lower,
110  CT_punct,
111  };
112 
113  class Entry {
114  public:
115  char32_t _character;
116  CharType _char_type;
117  char _ascii_equiv;
118  char _ascii_additional;
119  char32_t _tolower_character;
120  char32_t _toupper_character;
121  AccentType _accent_type;
122  int _additional_flags;
123  };
124 
125  static const Entry *look_up(char32_t character);
126 
127  static wchar_t get_combining_accent(AccentType accent);
128 
129 private:
130  static void init();
131  static bool _initialized;
132 
133  typedef phash_map<char32_t, const Entry *, integer_hash<char32_t> > ByCharacter;
134  static ByCharacter *_by_character;
135  enum { max_direct_chars = 256 };
136  static const Entry *_direct_chars[max_direct_chars];
137 };
138 
139 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class mainly serves as a container for a largish table of the subset of the Unicode character se...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.