• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "ui/events/x/keysym_to_unicode.h"
6 
7 // Define XK_xxx before the #include of <X11/keysym.h> so that <X11/keysym.h>
8 // defines all KeySyms we need.
9 #define XK_MISCELLANY
10 #define XK_LATIN1
11 #define XK_LATIN2
12 #define XK_LATIN3
13 #define XK_LATIN4
14 #define XK_LATIN8
15 #define XK_LATIN9
16 #define XK_KATAKANA
17 #define XK_ARABIC
18 #define XK_CYRILLIC
19 #define XK_GREEK
20 #define XK_TECHNICAL
21 #define XK_SPECIAL
22 #define XK_PUBLISHING
23 #define XK_APL
24 #define XK_HEBREW
25 #define XK_THAI
26 #define XK_KOREAN
27 #define XK_ARMENIAN
28 #define XK_GEORGIAN
29 #define XK_CAUCASUS
30 #define XK_VIETNAMESE
31 #define XK_CURRENCY
32 #define XK_MATHEMATICAL
33 #define XK_BRAILLE
34 #define XK_SINHALA
35 #include <X11/X.h>
36 #include <X11/keysym.h>
37 
38 #include <unordered_map>
39 
40 #include "base/lazy_instance.h"
41 #include "base/macros.h"
42 
43 namespace ui {
44 
45 const struct {
46   KeySym keysym;
47   uint16_t unicode;
48 } g_keysym_to_unicode_table[] = {
49   // Control characters
50   {XK_BackSpace,                   0x0008},
51   {XK_Tab,                         0x0009},
52   {XK_Linefeed,                    0x000a},
53   {XK_Clear,                       0x000b},
54   {XK_Return,                      0x000d},
55   {XK_Escape,                      0x001b},
56   {XK_Delete,                      0x007f},
57 
58   // Numeric keypad
59   {XK_KP_Space,                    0x0020},
60   {XK_KP_Tab,                      0x0009},
61   {XK_KP_Enter,                    0x000d},
62   {XK_KP_Equal,                    0x003d},
63   {XK_KP_Multiply,                 0x002a},
64   {XK_KP_Add,                      0x002b},
65   {XK_KP_Separator,                0x002c},
66   {XK_KP_Subtract,                 0x002d},
67   {XK_KP_Decimal,                  0x002e},
68   {XK_KP_Divide,                   0x002f},
69   {XK_KP_0,                        0x0030},
70   {XK_KP_1,                        0x0031},
71   {XK_KP_2,                        0x0032},
72   {XK_KP_3,                        0x0033},
73   {XK_KP_4,                        0x0034},
74   {XK_KP_5,                        0x0035},
75   {XK_KP_6,                        0x0036},
76   {XK_KP_7,                        0x0037},
77   {XK_KP_8,                        0x0038},
78   {XK_KP_9,                        0x0039},
79 
80   // Latin 1 KeySyms map 1:1 to Unicode
81 
82   // Latin 2
83   {XK_Aogonek,                     0x0104},  // LATIN CAPITAL LETTER A WITH OGONEK
84   {XK_breve,                       0x02D8},  // BREVE
85   {XK_Lstroke,                     0x0141},  // LATIN CAPITAL LETTER L WITH STROKE
86   {XK_Lcaron,                      0x013D},  // LATIN CAPITAL LETTER L WITH CARON
87   {XK_Sacute,                      0x015A},  // LATIN CAPITAL LETTER S WITH ACUTE
88   {XK_Scaron,                      0x0160},  // LATIN CAPITAL LETTER S WITH CARON
89   {XK_Scedilla,                    0x015E},  // LATIN CAPITAL LETTER S WITH CEDILLA
90   {XK_Tcaron,                      0x0164},  // LATIN CAPITAL LETTER T WITH CARON
91   {XK_Zacute,                      0x0179},  // LATIN CAPITAL LETTER Z WITH ACUTE
92   {XK_Zcaron,                      0x017D},  // LATIN CAPITAL LETTER Z WITH CARON
93   {XK_Zabovedot,                   0x017B},  // LATIN CAPITAL LETTER Z WITH DOT ABOVE
94   {XK_aogonek,                     0x0105},  // LATIN SMALL LETTER A WITH OGONEK
95   {XK_ogonek,                      0x02DB},  // OGONEK
96   {XK_lstroke,                     0x0142},  // LATIN SMALL LETTER L WITH STROKE
97   {XK_lcaron,                      0x013E},  // LATIN SMALL LETTER L WITH CARON
98   {XK_sacute,                      0x015B},  // LATIN SMALL LETTER S WITH ACUTE
99   {XK_caron,                       0x02C7},  // CARON
100   {XK_scaron,                      0x0161},  // LATIN SMALL LETTER S WITH CARON
101   {XK_scedilla,                    0x015F},  // LATIN SMALL LETTER S WITH CEDILLA
102   {XK_tcaron,                      0x0165},  // LATIN SMALL LETTER T WITH CARON
103   {XK_zacute,                      0x017A},  // LATIN SMALL LETTER Z WITH ACUTE
104   {XK_doubleacute,                 0x02DD},  // DOUBLE ACUTE ACCENT
105   {XK_zcaron,                      0x017E},  // LATIN SMALL LETTER Z WITH CARON
106   {XK_zabovedot,                   0x017C},  // LATIN SMALL LETTER Z WITH DOT ABOVE
107   {XK_Racute,                      0x0154},  // LATIN CAPITAL LETTER R WITH ACUTE
108   {XK_Abreve,                      0x0102},  // LATIN CAPITAL LETTER A WITH BREVE
109   {XK_Lacute,                      0x0139},  // LATIN CAPITAL LETTER L WITH ACUTE
110   {XK_Cacute,                      0x0106},  // LATIN CAPITAL LETTER C WITH ACUTE
111   {XK_Ccaron,                      0x010C},  // LATIN CAPITAL LETTER C WITH CARON
112   {XK_Eogonek,                     0x0118},  // LATIN CAPITAL LETTER E WITH OGONEK
113   {XK_Ecaron,                      0x011A},  // LATIN CAPITAL LETTER E WITH CARON
114   {XK_Dcaron,                      0x010E},  // LATIN CAPITAL LETTER D WITH CARON
115   {XK_Dstroke,                     0x0110},  // LATIN CAPITAL LETTER D WITH STROKE
116   {XK_Nacute,                      0x0143},  // LATIN CAPITAL LETTER N WITH ACUTE
117   {XK_Ncaron,                      0x0147},  // LATIN CAPITAL LETTER N WITH CARON
118   {XK_Odoubleacute,                0x0150},  // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
119   {XK_Rcaron,                      0x0158},  // LATIN CAPITAL LETTER R WITH CARON
120   {XK_Uring,                       0x016E},  // LATIN CAPITAL LETTER U WITH RING ABOVE
121   {XK_Udoubleacute,                0x0170},  // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
122   {XK_Tcedilla,                    0x0162},  // LATIN CAPITAL LETTER T WITH CEDILLA
123   {XK_racute,                      0x0155},  // LATIN SMALL LETTER R WITH ACUTE
124   {XK_abreve,                      0x0103},  // LATIN SMALL LETTER A WITH BREVE
125   {XK_lacute,                      0x013A},  // LATIN SMALL LETTER L WITH ACUTE
126   {XK_cacute,                      0x0107},  // LATIN SMALL LETTER C WITH ACUTE
127   {XK_ccaron,                      0x010D},  // LATIN SMALL LETTER C WITH CARON
128   {XK_eogonek,                     0x0119},  // LATIN SMALL LETTER E WITH OGONEK
129   {XK_ecaron,                      0x011B},  // LATIN SMALL LETTER E WITH CARON
130   {XK_dcaron,                      0x010F},  // LATIN SMALL LETTER D WITH CARON
131   {XK_dstroke,                     0x0111},  // LATIN SMALL LETTER D WITH STROKE
132   {XK_nacute,                      0x0144},  // LATIN SMALL LETTER N WITH ACUTE
133   {XK_ncaron,                      0x0148},  // LATIN SMALL LETTER N WITH CARON
134   {XK_odoubleacute,                0x0151},  // LATIN SMALL LETTER O WITH DOUBLE ACUTE
135   {XK_rcaron,                      0x0159},  // LATIN SMALL LETTER R WITH CARON
136   {XK_uring,                       0x016F},  // LATIN SMALL LETTER U WITH RING ABOVE
137   {XK_udoubleacute,                0x0171},  // LATIN SMALL LETTER U WITH DOUBLE ACUTE
138   {XK_tcedilla,                    0x0163},  // LATIN SMALL LETTER T WITH CEDILLA
139   {XK_abovedot,                    0x02D9},  // DOT ABOVE
140 
141   // Latin 3
142   {XK_Hstroke,                     0x0126},  // LATIN CAPITAL LETTER H WITH STROKE
143   {XK_Hcircumflex,                 0x0124},  // LATIN CAPITAL LETTER H WITH CIRCUMFLEX
144   {XK_Iabovedot,                   0x0130},  // LATIN CAPITAL LETTER I WITH DOT ABOVE
145   {XK_Gbreve,                      0x011E},  // LATIN CAPITAL LETTER G WITH BREVE
146   {XK_Jcircumflex,                 0x0134},  // LATIN CAPITAL LETTER J WITH CIRCUMFLEX
147   {XK_hstroke,                     0x0127},  // LATIN SMALL LETTER H WITH STROKE
148   {XK_hcircumflex,                 0x0125},  // LATIN SMALL LETTER H WITH CIRCUMFLEX
149   {XK_idotless,                    0x0131},  // LATIN SMALL LETTER DOTLESS I
150   {XK_gbreve,                      0x011F},  // LATIN SMALL LETTER G WITH BREVE
151   {XK_jcircumflex,                 0x0135},  // LATIN SMALL LETTER J WITH CIRCUMFLEX
152   {XK_Cabovedot,                   0x010A},  // LATIN CAPITAL LETTER C WITH DOT ABOVE
153   {XK_Ccircumflex,                 0x0108},  // LATIN CAPITAL LETTER C WITH CIRCUMFLEX
154   {XK_Gabovedot,                   0x0120},  // LATIN CAPITAL LETTER G WITH DOT ABOVE
155   {XK_Gcircumflex,                 0x011C},  // LATIN CAPITAL LETTER G WITH CIRCUMFLEX
156   {XK_Ubreve,                      0x016C},  // LATIN CAPITAL LETTER U WITH BREVE
157   {XK_Scircumflex,                 0x015C},  // LATIN CAPITAL LETTER S WITH CIRCUMFLEX
158   {XK_cabovedot,                   0x010B},  // LATIN SMALL LETTER C WITH DOT ABOVE
159   {XK_ccircumflex,                 0x0109},  // LATIN SMALL LETTER C WITH CIRCUMFLEX
160   {XK_gabovedot,                   0x0121},  // LATIN SMALL LETTER G WITH DOT ABOVE
161   {XK_gcircumflex,                 0x011D},  // LATIN SMALL LETTER G WITH CIRCUMFLEX
162   {XK_ubreve,                      0x016D},  // LATIN SMALL LETTER U WITH BREVE
163   {XK_scircumflex,                 0x015D},  // LATIN SMALL LETTER S WITH CIRCUMFLEX
164 
165   // Latin 4
166   {XK_kra,                         0x0138},  // LATIN SMALL LETTER KRA
167   {XK_Rcedilla,                    0x0156},  // LATIN CAPITAL LETTER R WITH CEDILLA
168   {XK_Itilde,                      0x0128},  // LATIN CAPITAL LETTER I WITH TILDE
169   {XK_Lcedilla,                    0x013B},  // LATIN CAPITAL LETTER L WITH CEDILLA
170   {XK_Emacron,                     0x0112},  // LATIN CAPITAL LETTER E WITH MACRON
171   {XK_Gcedilla,                    0x0122},  // LATIN CAPITAL LETTER G WITH CEDILLA
172   {XK_Tslash,                      0x0166},  // LATIN CAPITAL LETTER T WITH STROKE
173   {XK_rcedilla,                    0x0157},  // LATIN SMALL LETTER R WITH CEDILLA
174   {XK_itilde,                      0x0129},  // LATIN SMALL LETTER I WITH TILDE
175   {XK_lcedilla,                    0x013C},  // LATIN SMALL LETTER L WITH CEDILLA
176   {XK_emacron,                     0x0113},  // LATIN SMALL LETTER E WITH MACRON
177   {XK_gcedilla,                    0x0123},  // LATIN SMALL LETTER G WITH CEDILLA
178   {XK_tslash,                      0x0167},  // LATIN SMALL LETTER T WITH STROKE
179   {XK_ENG,                         0x014A},  // LATIN CAPITAL LETTER ENG
180   {XK_eng,                         0x014B},  // LATIN SMALL LETTER ENG
181   {XK_Amacron,                     0x0100},  // LATIN CAPITAL LETTER A WITH MACRON
182   {XK_Iogonek,                     0x012E},  // LATIN CAPITAL LETTER I WITH OGONEK
183   {XK_Eabovedot,                   0x0116},  // LATIN CAPITAL LETTER E WITH DOT ABOVE
184   {XK_Imacron,                     0x012A},  // LATIN CAPITAL LETTER I WITH MACRON
185   {XK_Ncedilla,                    0x0145},  // LATIN CAPITAL LETTER N WITH CEDILLA
186   {XK_Omacron,                     0x014C},  // LATIN CAPITAL LETTER O WITH MACRON
187   {XK_Kcedilla,                    0x0136},  // LATIN CAPITAL LETTER K WITH CEDILLA
188   {XK_Uogonek,                     0x0172},  // LATIN CAPITAL LETTER U WITH OGONEK
189   {XK_Utilde,                      0x0168},  // LATIN CAPITAL LETTER U WITH TILDE
190   {XK_Umacron,                     0x016A},  // LATIN CAPITAL LETTER U WITH MACRON
191   {XK_amacron,                     0x0101},  // LATIN SMALL LETTER A WITH MACRON
192   {XK_iogonek,                     0x012F},  // LATIN SMALL LETTER I WITH OGONEK
193   {XK_eabovedot,                   0x0117},  // LATIN SMALL LETTER E WITH DOT ABOVE
194   {XK_imacron,                     0x012B},  // LATIN SMALL LETTER I WITH MACRON
195   {XK_ncedilla,                    0x0146},  // LATIN SMALL LETTER N WITH CEDILLA
196   {XK_omacron,                     0x014D},  // LATIN SMALL LETTER O WITH MACRON
197   {XK_kcedilla,                    0x0137},  // LATIN SMALL LETTER K WITH CEDILLA
198   {XK_uogonek,                     0x0173},  // LATIN SMALL LETTER U WITH OGONEK
199   {XK_utilde,                      0x0169},  // LATIN SMALL LETTER U WITH TILDE
200   {XK_umacron,                     0x016B},  // LATIN SMALL LETTER U WITH MACRON
201 
202   // Latin 8 KeySyms map 1:1 to Unicode
203 
204   // Latin 9
205   {XK_OE,                          0x0152},  // LATIN CAPITAL LIGATURE OE
206   {XK_oe,                          0x0153},  // LATIN SMALL LIGATURE OE
207   {XK_Ydiaeresis,                  0x0178},  // LATIN CAPITAL LETTER Y WITH DIAERESIS
208 
209   // Katakana
210   {XK_overline,                    0x203E},  // OVERLINE
211   {XK_kana_fullstop,               0x3002},  // IDEOGRAPHIC FULL STOP
212   {XK_kana_openingbracket,         0x300C},  // LEFT CORNER BRACKET
213   {XK_kana_closingbracket,         0x300D},  // RIGHT CORNER BRACKET
214   {XK_kana_comma,                  0x3001},  // IDEOGRAPHIC COMMA
215   {XK_kana_conjunctive,            0x30FB},  // KATAKANA MIDDLE DOT
216   {XK_kana_WO,                     0x30F2},  // KATAKANA LETTER WO
217   {XK_kana_a,                      0x30A1},  // KATAKANA LETTER SMALL A
218   {XK_kana_i,                      0x30A3},  // KATAKANA LETTER SMALL I
219   {XK_kana_u,                      0x30A5},  // KATAKANA LETTER SMALL U
220   {XK_kana_e,                      0x30A7},  // KATAKANA LETTER SMALL E
221   {XK_kana_o,                      0x30A9},  // KATAKANA LETTER SMALL O
222   {XK_kana_ya,                     0x30E3},  // KATAKANA LETTER SMALL YA
223   {XK_kana_yu,                     0x30E5},  // KATAKANA LETTER SMALL YU
224   {XK_kana_yo,                     0x30E7},  // KATAKANA LETTER SMALL YO
225   {XK_kana_tsu,                    0x30C3},  // KATAKANA LETTER SMALL TU
226   {XK_prolongedsound,              0x30FC},  // KATAKANA-HIRAGANA PROLONGED SOUND MARK
227   {XK_kana_A,                      0x30A2},  // KATAKANA LETTER A
228   {XK_kana_I,                      0x30A4},  // KATAKANA LETTER I
229   {XK_kana_U,                      0x30A6},  // KATAKANA LETTER U
230   {XK_kana_E,                      0x30A8},  // KATAKANA LETTER E
231   {XK_kana_O,                      0x30AA},  // KATAKANA LETTER O
232   {XK_kana_KA,                     0x30AB},  // KATAKANA LETTER KA
233   {XK_kana_KI,                     0x30AD},  // KATAKANA LETTER KI
234   {XK_kana_KU,                     0x30AF},  // KATAKANA LETTER KU
235   {XK_kana_KE,                     0x30B1},  // KATAKANA LETTER KE
236   {XK_kana_KO,                     0x30B3},  // KATAKANA LETTER KO
237   {XK_kana_SA,                     0x30B5},  // KATAKANA LETTER SA
238   {XK_kana_SHI,                    0x30B7},  // KATAKANA LETTER SI
239   {XK_kana_SU,                     0x30B9},  // KATAKANA LETTER SU
240   {XK_kana_SE,                     0x30BB},  // KATAKANA LETTER SE
241   {XK_kana_SO,                     0x30BD},  // KATAKANA LETTER SO
242   {XK_kana_TA,                     0x30BF},  // KATAKANA LETTER TA
243   {XK_kana_CHI,                    0x30C1},  // KATAKANA LETTER TI
244   {XK_kana_TSU,                    0x30C4},  // KATAKANA LETTER TU
245   {XK_kana_TE,                     0x30C6},  // KATAKANA LETTER TE
246   {XK_kana_TO,                     0x30C8},  // KATAKANA LETTER TO
247   {XK_kana_NA,                     0x30CA},  // KATAKANA LETTER NA
248   {XK_kana_NI,                     0x30CB},  // KATAKANA LETTER NI
249   {XK_kana_NU,                     0x30CC},  // KATAKANA LETTER NU
250   {XK_kana_NE,                     0x30CD},  // KATAKANA LETTER NE
251   {XK_kana_NO,                     0x30CE},  // KATAKANA LETTER NO
252   {XK_kana_HA,                     0x30CF},  // KATAKANA LETTER HA
253   {XK_kana_HI,                     0x30D2},  // KATAKANA LETTER HI
254   {XK_kana_FU,                     0x30D5},  // KATAKANA LETTER HU
255   {XK_kana_HE,                     0x30D8},  // KATAKANA LETTER HE
256   {XK_kana_HO,                     0x30DB},  // KATAKANA LETTER HO
257   {XK_kana_MA,                     0x30DE},  // KATAKANA LETTER MA
258   {XK_kana_MI,                     0x30DF},  // KATAKANA LETTER MI
259   {XK_kana_MU,                     0x30E0},  // KATAKANA LETTER MU
260   {XK_kana_ME,                     0x30E1},  // KATAKANA LETTER ME
261   {XK_kana_MO,                     0x30E2},  // KATAKANA LETTER MO
262   {XK_kana_YA,                     0x30E4},  // KATAKANA LETTER YA
263   {XK_kana_YU,                     0x30E6},  // KATAKANA LETTER YU
264   {XK_kana_YO,                     0x30E8},  // KATAKANA LETTER YO
265   {XK_kana_RA,                     0x30E9},  // KATAKANA LETTER RA
266   {XK_kana_RI,                     0x30EA},  // KATAKANA LETTER RI
267   {XK_kana_RU,                     0x30EB},  // KATAKANA LETTER RU
268   {XK_kana_RE,                     0x30EC},  // KATAKANA LETTER RE
269   {XK_kana_RO,                     0x30ED},  // KATAKANA LETTER RO
270   {XK_kana_WA,                     0x30EF},  // KATAKANA LETTER WA
271   {XK_kana_N,                      0x30F3},  // KATAKANA LETTER N
272   {XK_voicedsound,                 0x309B},  // KATAKANA-HIRAGANA VOICED SOUND MARK
273   {XK_semivoicedsound,             0x309C},  // KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
274 
275   // Arabic KeySyms partially map 1:1 to Unicode
276   {XK_Arabic_comma,                0x060C},  // ARABIC COMMA
277   {XK_Arabic_semicolon,            0x061B},  // ARABIC SEMICOLON
278   {XK_Arabic_question_mark,        0x061F},  // ARABIC QUESTION MARK
279   {XK_Arabic_hamza,                0x0621},  // ARABIC LETTER HAMZA
280   {XK_Arabic_maddaonalef,          0x0622},  // ARABIC LETTER ALEF WITH MADDA ABOVE
281   {XK_Arabic_hamzaonalef,          0x0623},  // ARABIC LETTER ALEF WITH HAMZA ABOVE
282   {XK_Arabic_hamzaonwaw,           0x0624},  // ARABIC LETTER WAW WITH HAMZA ABOVE
283   {XK_Arabic_hamzaunderalef,       0x0625},  // ARABIC LETTER ALEF WITH HAMZA BELOW
284   {XK_Arabic_hamzaonyeh,           0x0626},  // ARABIC LETTER YEH WITH HAMZA ABOVE
285   {XK_Arabic_alef,                 0x0627},  // ARABIC LETTER ALEF
286   {XK_Arabic_beh,                  0x0628},  // ARABIC LETTER BEH
287   {XK_Arabic_tehmarbuta,           0x0629},  // ARABIC LETTER TEH MARBUTA
288   {XK_Arabic_teh,                  0x062A},  // ARABIC LETTER TEH
289   {XK_Arabic_theh,                 0x062B},  // ARABIC LETTER THEH
290   {XK_Arabic_jeem,                 0x062C},  // ARABIC LETTER JEEM
291   {XK_Arabic_hah,                  0x062D},  // ARABIC LETTER HAH
292   {XK_Arabic_khah,                 0x062E},  // ARABIC LETTER KHAH
293   {XK_Arabic_dal,                  0x062F},  // ARABIC LETTER DAL
294   {XK_Arabic_thal,                 0x0630},  // ARABIC LETTER THAL
295   {XK_Arabic_ra,                   0x0631},  // ARABIC LETTER REH
296   {XK_Arabic_zain,                 0x0632},  // ARABIC LETTER ZAIN
297   {XK_Arabic_seen,                 0x0633},  // ARABIC LETTER SEEN
298   {XK_Arabic_sheen,                0x0634},  // ARABIC LETTER SHEEN
299   {XK_Arabic_sad,                  0x0635},  // ARABIC LETTER SAD
300   {XK_Arabic_dad,                  0x0636},  // ARABIC LETTER DAD
301   {XK_Arabic_tah,                  0x0637},  // ARABIC LETTER TAH
302   {XK_Arabic_zah,                  0x0638},  // ARABIC LETTER ZAH
303   {XK_Arabic_ain,                  0x0639},  // ARABIC LETTER AIN
304   {XK_Arabic_ghain,                0x063A},  // ARABIC LETTER GHAIN
305   {XK_Arabic_tatweel,              0x0640},  // ARABIC TATWEEL
306   {XK_Arabic_feh,                  0x0641},  // ARABIC LETTER FEH
307   {XK_Arabic_qaf,                  0x0642},  // ARABIC LETTER QAF
308   {XK_Arabic_kaf,                  0x0643},  // ARABIC LETTER KAF
309   {XK_Arabic_lam,                  0x0644},  // ARABIC LETTER LAM
310   {XK_Arabic_meem,                 0x0645},  // ARABIC LETTER MEEM
311   {XK_Arabic_noon,                 0x0646},  // ARABIC LETTER NOON
312   {XK_Arabic_ha,                   0x0647},  // ARABIC LETTER HEH
313   {XK_Arabic_waw,                  0x0648},  // ARABIC LETTER WAW
314   {XK_Arabic_alefmaksura,          0x0649},  // ARABIC LETTER ALEF MAKSURA
315   {XK_Arabic_yeh,                  0x064A},  // ARABIC LETTER YEH
316   {XK_Arabic_fathatan,             0x064B},  // ARABIC FATHATAN
317   {XK_Arabic_dammatan,             0x064C},  // ARABIC DAMMATAN
318   {XK_Arabic_kasratan,             0x064D},  // ARABIC KASRATAN
319   {XK_Arabic_fatha,                0x064E},  // ARABIC FATHA
320   {XK_Arabic_damma,                0x064F},  // ARABIC DAMMA
321   {XK_Arabic_kasra,                0x0650},  // ARABIC KASRA
322   {XK_Arabic_shadda,               0x0651},  // ARABIC SHADDA
323   {XK_Arabic_sukun,                0x0652},  // ARABIC SUKUN
324 
325   // Cyrillic KeySyms partially map 1:1 to Unicode
326   {XK_Serbian_dje,                 0x0452},  // CYRILLIC SMALL LETTER DJE
327   {XK_Macedonia_gje,               0x0453},  // CYRILLIC SMALL LETTER GJE
328   {XK_Cyrillic_io,                 0x0451},  // CYRILLIC SMALL LETTER IO
329   {XK_Ukrainian_ie,                0x0454},  // CYRILLIC SMALL LETTER UKRAINIAN IE
330   {XK_Macedonia_dse,               0x0455},  // CYRILLIC SMALL LETTER DZE
331   {XK_Ukrainian_i,                 0x0456},  // CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
332   {XK_Ukrainian_yi,                0x0457},  // CYRILLIC SMALL LETTER YI
333   {XK_Cyrillic_je,                 0x0458},  // CYRILLIC SMALL LETTER JE
334   {XK_Cyrillic_lje,                0x0459},  // CYRILLIC SMALL LETTER LJE
335   {XK_Cyrillic_nje,                0x045A},  // CYRILLIC SMALL LETTER NJE
336   {XK_Serbian_tshe,                0x045B},  // CYRILLIC SMALL LETTER TSHE
337   {XK_Macedonia_kje,               0x045C},  // CYRILLIC SMALL LETTER KJE
338   {XK_Ukrainian_ghe_with_upturn,   0x0491},  // CYRILLIC SMALL LETTER GHE WITH UPTURN
339   {XK_Byelorussian_shortu,         0x045E},  // CYRILLIC SMALL LETTER SHORT U
340   {XK_Cyrillic_dzhe,               0x045F},  // CYRILLIC SMALL LETTER DZHE
341   {XK_numerosign,                  0x2116},  // NUMERO SIGN
342   {XK_Serbian_DJE,                 0x0402},  // CYRILLIC CAPITAL LETTER DJE
343   {XK_Macedonia_GJE,               0x0403},  // CYRILLIC CAPITAL LETTER GJE
344   {XK_Cyrillic_IO,                 0x0401},  // CYRILLIC CAPITAL LETTER IO
345   {XK_Ukrainian_IE,                0x0404},  // CYRILLIC CAPITAL LETTER UKRAINIAN IE
346   {XK_Macedonia_DSE,               0x0405},  // CYRILLIC CAPITAL LETTER DZE
347   {XK_Ukrainian_I,                 0x0406},  // CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
348   {XK_Ukrainian_YI,                0x0407},  // CYRILLIC CAPITAL LETTER YI
349   {XK_Cyrillic_JE,                 0x0408},  // CYRILLIC CAPITAL LETTER JE
350   {XK_Cyrillic_LJE,                0x0409},  // CYRILLIC CAPITAL LETTER LJE
351   {XK_Cyrillic_NJE,                0x040A},  // CYRILLIC CAPITAL LETTER NJE
352   {XK_Serbian_TSHE,                0x040B},  // CYRILLIC CAPITAL LETTER TSHE
353   {XK_Macedonia_KJE,               0x040C},  // CYRILLIC CAPITAL LETTER KJE
354   {XK_Ukrainian_GHE_WITH_UPTURN,   0x0490},  // CYRILLIC CAPITAL LETTER GHE WITH UPTURN
355   {XK_Byelorussian_SHORTU,         0x040E},  // CYRILLIC CAPITAL LETTER SHORT U
356   {XK_Cyrillic_DZHE,               0x040F},  // CYRILLIC CAPITAL LETTER DZHE
357   {XK_Cyrillic_yu,                 0x044E},  // CYRILLIC SMALL LETTER YU
358   {XK_Cyrillic_a,                  0x0430},  // CYRILLIC SMALL LETTER A
359   {XK_Cyrillic_be,                 0x0431},  // CYRILLIC SMALL LETTER BE
360   {XK_Cyrillic_tse,                0x0446},  // CYRILLIC SMALL LETTER TSE
361   {XK_Cyrillic_de,                 0x0434},  // CYRILLIC SMALL LETTER DE
362   {XK_Cyrillic_ie,                 0x0435},  // CYRILLIC SMALL LETTER IE
363   {XK_Cyrillic_ef,                 0x0444},  // CYRILLIC SMALL LETTER EF
364   {XK_Cyrillic_ghe,                0x0433},  // CYRILLIC SMALL LETTER GHE
365   {XK_Cyrillic_ha,                 0x0445},  // CYRILLIC SMALL LETTER HA
366   {XK_Cyrillic_i,                  0x0438},  // CYRILLIC SMALL LETTER I
367   {XK_Cyrillic_shorti,             0x0439},  // CYRILLIC SMALL LETTER SHORT I
368   {XK_Cyrillic_ka,                 0x043A},  // CYRILLIC SMALL LETTER KA
369   {XK_Cyrillic_el,                 0x043B},  // CYRILLIC SMALL LETTER EL
370   {XK_Cyrillic_em,                 0x043C},  // CYRILLIC SMALL LETTER EM
371   {XK_Cyrillic_en,                 0x043D},  // CYRILLIC SMALL LETTER EN
372   {XK_Cyrillic_o,                  0x043E},  // CYRILLIC SMALL LETTER O
373   {XK_Cyrillic_pe,                 0x043F},  // CYRILLIC SMALL LETTER PE
374   {XK_Cyrillic_ya,                 0x044F},  // CYRILLIC SMALL LETTER YA
375   {XK_Cyrillic_er,                 0x0440},  // CYRILLIC SMALL LETTER ER
376   {XK_Cyrillic_es,                 0x0441},  // CYRILLIC SMALL LETTER ES
377   {XK_Cyrillic_te,                 0x0442},  // CYRILLIC SMALL LETTER TE
378   {XK_Cyrillic_u,                  0x0443},  // CYRILLIC SMALL LETTER U
379   {XK_Cyrillic_zhe,                0x0436},  // CYRILLIC SMALL LETTER ZHE
380   {XK_Cyrillic_ve,                 0x0432},  // CYRILLIC SMALL LETTER VE
381   {XK_Cyrillic_softsign,           0x044C},  // CYRILLIC SMALL LETTER SOFT SIGN
382   {XK_Cyrillic_yeru,               0x044B},  // CYRILLIC SMALL LETTER YERU
383   {XK_Cyrillic_ze,                 0x0437},  // CYRILLIC SMALL LETTER ZE
384   {XK_Cyrillic_sha,                0x0448},  // CYRILLIC SMALL LETTER SHA
385   {XK_Cyrillic_e,                  0x044D},  // CYRILLIC SMALL LETTER E
386   {XK_Cyrillic_shcha,              0x0449},  // CYRILLIC SMALL LETTER SHCHA
387   {XK_Cyrillic_che,                0x0447},  // CYRILLIC SMALL LETTER CHE
388   {XK_Cyrillic_hardsign,           0x044A},  // CYRILLIC SMALL LETTER HARD SIGN
389   {XK_Cyrillic_YU,                 0x042E},  // CYRILLIC CAPITAL LETTER YU
390   {XK_Cyrillic_A,                  0x0410},  // CYRILLIC CAPITAL LETTER A
391   {XK_Cyrillic_BE,                 0x0411},  // CYRILLIC CAPITAL LETTER BE
392   {XK_Cyrillic_TSE,                0x0426},  // CYRILLIC CAPITAL LETTER TSE
393   {XK_Cyrillic_DE,                 0x0414},  // CYRILLIC CAPITAL LETTER DE
394   {XK_Cyrillic_IE,                 0x0415},  // CYRILLIC CAPITAL LETTER IE
395   {XK_Cyrillic_EF,                 0x0424},  // CYRILLIC CAPITAL LETTER EF
396   {XK_Cyrillic_GHE,                0x0413},  // CYRILLIC CAPITAL LETTER GHE
397   {XK_Cyrillic_HA,                 0x0425},  // CYRILLIC CAPITAL LETTER HA
398   {XK_Cyrillic_I,                  0x0418},  // CYRILLIC CAPITAL LETTER I
399   {XK_Cyrillic_SHORTI,             0x0419},  // CYRILLIC CAPITAL LETTER SHORT I
400   {XK_Cyrillic_KA,                 0x041A},  // CYRILLIC CAPITAL LETTER KA
401   {XK_Cyrillic_EL,                 0x041B},  // CYRILLIC CAPITAL LETTER EL
402   {XK_Cyrillic_EM,                 0x041C},  // CYRILLIC CAPITAL LETTER EM
403   {XK_Cyrillic_EN,                 0x041D},  // CYRILLIC CAPITAL LETTER EN
404   {XK_Cyrillic_O,                  0x041E},  // CYRILLIC CAPITAL LETTER O
405   {XK_Cyrillic_PE,                 0x041F},  // CYRILLIC CAPITAL LETTER PE
406   {XK_Cyrillic_YA,                 0x042F},  // CYRILLIC CAPITAL LETTER YA
407   {XK_Cyrillic_ER,                 0x0420},  // CYRILLIC CAPITAL LETTER ER
408   {XK_Cyrillic_ES,                 0x0421},  // CYRILLIC CAPITAL LETTER ES
409   {XK_Cyrillic_TE,                 0x0422},  // CYRILLIC CAPITAL LETTER TE
410   {XK_Cyrillic_U,                  0x0423},  // CYRILLIC CAPITAL LETTER U
411   {XK_Cyrillic_ZHE,                0x0416},  // CYRILLIC CAPITAL LETTER ZHE
412   {XK_Cyrillic_VE,                 0x0412},  // CYRILLIC CAPITAL LETTER VE
413   {XK_Cyrillic_SOFTSIGN,           0x042C},  // CYRILLIC CAPITAL LETTER SOFT SIGN
414   {XK_Cyrillic_YERU,               0x042B},  // CYRILLIC CAPITAL LETTER YERU
415   {XK_Cyrillic_ZE,                 0x0417},  // CYRILLIC CAPITAL LETTER ZE
416   {XK_Cyrillic_SHA,                0x0428},  // CYRILLIC CAPITAL LETTER SHA
417   {XK_Cyrillic_E,                  0x042D},  // CYRILLIC CAPITAL LETTER E
418   {XK_Cyrillic_SHCHA,              0x0429},  // CYRILLIC CAPITAL LETTER SHCHA
419   {XK_Cyrillic_CHE,                0x0427},  // CYRILLIC CAPITAL LETTER CHE
420   {XK_Cyrillic_HARDSIGN,           0x042A},  // CYRILLIC CAPITAL LETTER HARD SIGN
421 
422   // Greek
423   {XK_Greek_ALPHAaccent,           0x0386},  // GREEK CAPITAL LETTER ALPHA WITH TONOS
424   {XK_Greek_EPSILONaccent,         0x0388},  // GREEK CAPITAL LETTER EPSILON WITH TONOS
425   {XK_Greek_ETAaccent,             0x0389},  // GREEK CAPITAL LETTER ETA WITH TONOS
426   {XK_Greek_IOTAaccent,            0x038A},  // GREEK CAPITAL LETTER IOTA WITH TONOS
427   {XK_Greek_IOTAdieresis,          0x03AA},  // GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
428   {XK_Greek_OMICRONaccent,         0x038C},  // GREEK CAPITAL LETTER OMICRON WITH TONOS
429   {XK_Greek_UPSILONaccent,         0x038E},  // GREEK CAPITAL LETTER UPSILON WITH TONOS
430   {XK_Greek_UPSILONdieresis,       0x03AB},  // GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
431   {XK_Greek_OMEGAaccent,           0x038F},  // GREEK CAPITAL LETTER OMEGA WITH TONOS
432   {XK_Greek_accentdieresis,        0x0385},  // GREEK DIALYTIKA TONOS
433   {XK_Greek_horizbar,              0x2015},  // HORIZONTAL BAR
434   {XK_Greek_alphaaccent,           0x03AC},  // GREEK SMALL LETTER ALPHA WITH TONOS
435   {XK_Greek_epsilonaccent,         0x03AD},  // GREEK SMALL LETTER EPSILON WITH TONOS
436   {XK_Greek_etaaccent,             0x03AE},  // GREEK SMALL LETTER ETA WITH TONOS
437   {XK_Greek_iotaaccent,            0x03AF},  // GREEK SMALL LETTER IOTA WITH TONOS
438   {XK_Greek_iotadieresis,          0x03CA},  // GREEK SMALL LETTER IOTA WITH DIALYTIKA
439   {XK_Greek_iotaaccentdieresis,    0x0390},  // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
440   {XK_Greek_omicronaccent,         0x03CC},  // GREEK SMALL LETTER OMICRON WITH TONOS
441   {XK_Greek_upsilonaccent,         0x03CD},  // GREEK SMALL LETTER UPSILON WITH TONOS
442   {XK_Greek_upsilondieresis,       0x03CB},  // GREEK SMALL LETTER UPSILON WITH DIALYTIKA
443   {XK_Greek_upsilonaccentdieresis, 0x03B0},  // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
444   {XK_Greek_omegaaccent,           0x03CE},  // GREEK SMALL LETTER OMEGA WITH TONOS
445   {XK_Greek_ALPHA,                 0x0391},  // GREEK CAPITAL LETTER ALPHA
446   {XK_Greek_BETA,                  0x0392},  // GREEK CAPITAL LETTER BETA
447   {XK_Greek_GAMMA,                 0x0393},  // GREEK CAPITAL LETTER GAMMA
448   {XK_Greek_DELTA,                 0x0394},  // GREEK CAPITAL LETTER DELTA
449   {XK_Greek_EPSILON,               0x0395},  // GREEK CAPITAL LETTER EPSILON
450   {XK_Greek_ZETA,                  0x0396},  // GREEK CAPITAL LETTER ZETA
451   {XK_Greek_ETA,                   0x0397},  // GREEK CAPITAL LETTER ETA
452   {XK_Greek_THETA,                 0x0398},  // GREEK CAPITAL LETTER THETA
453   {XK_Greek_IOTA,                  0x0399},  // GREEK CAPITAL LETTER IOTA
454   {XK_Greek_KAPPA,                 0x039A},  // GREEK CAPITAL LETTER KAPPA
455   {XK_Greek_LAMDA,                 0x039B},  // GREEK CAPITAL LETTER LAMDA
456   {XK_Greek_LAMBDA,                0x039B},  // GREEK CAPITAL LETTER LAMDA
457   {XK_Greek_MU,                    0x039C},  // GREEK CAPITAL LETTER MU
458   {XK_Greek_NU,                    0x039D},  // GREEK CAPITAL LETTER NU
459   {XK_Greek_XI,                    0x039E},  // GREEK CAPITAL LETTER XI
460   {XK_Greek_OMICRON,               0x039F},  // GREEK CAPITAL LETTER OMICRON
461   {XK_Greek_PI,                    0x03A0},  // GREEK CAPITAL LETTER PI
462   {XK_Greek_RHO,                   0x03A1},  // GREEK CAPITAL LETTER RHO
463   {XK_Greek_SIGMA,                 0x03A3},  // GREEK CAPITAL LETTER SIGMA
464   {XK_Greek_TAU,                   0x03A4},  // GREEK CAPITAL LETTER TAU
465   {XK_Greek_UPSILON,               0x03A5},  // GREEK CAPITAL LETTER UPSILON
466   {XK_Greek_PHI,                   0x03A6},  // GREEK CAPITAL LETTER PHI
467   {XK_Greek_CHI,                   0x03A7},  // GREEK CAPITAL LETTER CHI
468   {XK_Greek_PSI,                   0x03A8},  // GREEK CAPITAL LETTER PSI
469   {XK_Greek_OMEGA,                 0x03A9},  // GREEK CAPITAL LETTER OMEGA
470   {XK_Greek_alpha,                 0x03B1},  // GREEK SMALL LETTER ALPHA
471   {XK_Greek_beta,                  0x03B2},  // GREEK SMALL LETTER BETA
472   {XK_Greek_gamma,                 0x03B3},  // GREEK SMALL LETTER GAMMA
473   {XK_Greek_delta,                 0x03B4},  // GREEK SMALL LETTER DELTA
474   {XK_Greek_epsilon,               0x03B5},  // GREEK SMALL LETTER EPSILON
475   {XK_Greek_zeta,                  0x03B6},  // GREEK SMALL LETTER ZETA
476   {XK_Greek_eta,                   0x03B7},  // GREEK SMALL LETTER ETA
477   {XK_Greek_theta,                 0x03B8},  // GREEK SMALL LETTER THETA
478   {XK_Greek_iota,                  0x03B9},  // GREEK SMALL LETTER IOTA
479   {XK_Greek_kappa,                 0x03BA},  // GREEK SMALL LETTER KAPPA
480   {XK_Greek_lamda,                 0x03BB},  // GREEK SMALL LETTER LAMDA
481   {XK_Greek_lambda,                0x03BB},  // GREEK SMALL LETTER LAMDA
482   {XK_Greek_mu,                    0x03BC},  // GREEK SMALL LETTER MU
483   {XK_Greek_nu,                    0x03BD},  // GREEK SMALL LETTER NU
484   {XK_Greek_xi,                    0x03BE},  // GREEK SMALL LETTER XI
485   {XK_Greek_omicron,               0x03BF},  // GREEK SMALL LETTER OMICRON
486   {XK_Greek_pi,                    0x03C0},  // GREEK SMALL LETTER PI
487   {XK_Greek_rho,                   0x03C1},  // GREEK SMALL LETTER RHO
488   {XK_Greek_sigma,                 0x03C3},  // GREEK SMALL LETTER SIGMA
489   {XK_Greek_finalsmallsigma,       0x03C2},  // GREEK SMALL LETTER FINAL SIGMA
490   {XK_Greek_tau,                   0x03C4},  // GREEK SMALL LETTER TAU
491   {XK_Greek_upsilon,               0x03C5},  // GREEK SMALL LETTER UPSILON
492   {XK_Greek_phi,                   0x03C6},  // GREEK SMALL LETTER PHI
493   {XK_Greek_chi,                   0x03C7},  // GREEK SMALL LETTER CHI
494   {XK_Greek_psi,                   0x03C8},  // GREEK SMALL LETTER PSI
495   {XK_Greek_omega,                 0x03C9},  // GREEK SMALL LETTER OMEGA
496 
497   // Technical
498   {XK_leftradical,                 0x23B7},  // RADICAL SYMBOL BOTTOM
499   {XK_topleftradical,              0x250C},  // BOX DRAWINGS LIGHT DOWN AND RIGHT
500   {XK_horizconnector,              0x2500},  // BOX DRAWINGS LIGHT HORIZONTAL
501   {XK_topintegral,                 0x2320},  // TOP HALF INTEGRAL
502   {XK_botintegral,                 0x2321},  // BOTTOM HALF INTEGRAL
503   {XK_vertconnector,               0x2502},  // BOX DRAWINGS LIGHT VERTICAL
504   {XK_topleftsqbracket,            0x23A1},  // LEFT SQUARE BRACKET UPPER CORNER
505   {XK_botleftsqbracket,            0x23A3},  // LEFT SQUARE BRACKET LOWER CORNER
506   {XK_toprightsqbracket,           0x23A4},  // RIGHT SQUARE BRACKET UPPER CORNER
507   {XK_botrightsqbracket,           0x23A6},  // RIGHT SQUARE BRACKET LOWER CORNER
508   {XK_topleftparens,               0x239B},  // LEFT PARENTHESIS UPPER HOOK
509   {XK_botleftparens,               0x239D},  // LEFT PARENTHESIS LOWER HOOK
510   {XK_toprightparens,              0x239E},  // RIGHT PARENTHESIS UPPER HOOK
511   {XK_botrightparens,              0x23A0},  // RIGHT PARENTHESIS LOWER HOOK
512   {XK_leftmiddlecurlybrace,        0x23A8},  // LEFT CURLY BRACKET MIDDLE PIECE
513   {XK_rightmiddlecurlybrace,       0x23AC},  // RIGHT CURLY BRACKET MIDDLE PIECE
514   {XK_lessthanequal,               0x2264},  // LESS-THAN OR EQUAL TO
515   {XK_notequal,                    0x2260},  // NOT EQUAL TO
516   {XK_greaterthanequal,            0x2265},  // GREATER-THAN OR EQUAL TO
517   {XK_integral,                    0x222B},  // INTEGRAL
518   {XK_therefore,                   0x2234},  // THEREFORE
519   {XK_variation,                   0x221D},  // PROPORTIONAL TO
520   {XK_infinity,                    0x221E},  // INFINITY
521   {XK_nabla,                       0x2207},  // NABLA
522   {XK_approximate,                 0x223C},  // TILDE OPERATOR
523   {XK_similarequal,                0x2243},  // ASYMPTOTICALLY EQUAL TO
524   {XK_ifonlyif,                    0x21D4},  // LEFT RIGHT DOUBLE ARROW
525   {XK_implies,                     0x21D2},  // RIGHTWARDS DOUBLE ARROW
526   {XK_identical,                   0x2261},  // IDENTICAL TO
527   {XK_radical,                     0x221A},  // SQUARE ROOT
528   {XK_includedin,                  0x2282},  // SUBSET OF
529   {XK_includes,                    0x2283},  // SUPERSET OF
530   {XK_intersection,                0x2229},  // INTERSECTION
531   {XK_union,                       0x222A},  // UNION
532   {XK_logicaland,                  0x2227},  // LOGICAL AND
533   {XK_logicalor,                   0x2228},  // LOGICAL OR
534   {XK_partialderivative,           0x2202},  // PARTIAL DIFFERENTIAL
535   {XK_function,                    0x0192},  // LATIN SMALL LETTER F WITH HOOK
536   {XK_leftarrow,                   0x2190},  // LEFTWARDS ARROW
537   {XK_uparrow,                     0x2191},  // UPWARDS ARROW
538   {XK_rightarrow,                  0x2192},  // RIGHTWARDS ARROW
539   {XK_downarrow,                   0x2193},  // DOWNWARDS ARROW
540 
541   // Special
542   {XK_soliddiamond,                0x25C6},  // BLACK DIAMOND
543   {XK_checkerboard,                0x2592},  // MEDIUM SHADE
544   {XK_ht,                          0x2409},  // SYMBOL FOR HORIZONTAL TABULATION
545   {XK_ff,                          0x240C},  // SYMBOL FOR FORM FEED
546   {XK_cr,                          0x240D},  // SYMBOL FOR CARRIAGE RETURN
547   {XK_lf,                          0x240A},  // SYMBOL FOR LINE FEED
548   {XK_nl,                          0x2424},  // SYMBOL FOR NEWLINE
549   {XK_vt,                          0x240B},  // SYMBOL FOR VERTICAL TABULATION
550   {XK_lowrightcorner,              0x2518},  // BOX DRAWINGS LIGHT UP AND LEFT
551   {XK_uprightcorner,               0x2510},  // BOX DRAWINGS LIGHT DOWN AND LEFT
552   {XK_upleftcorner,                0x250C},  // BOX DRAWINGS LIGHT DOWN AND RIGHT
553   {XK_lowleftcorner,               0x2514},  // BOX DRAWINGS LIGHT UP AND RIGHT
554   {XK_crossinglines,               0x253C},  // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
555   {XK_horizlinescan1,              0x23BA},  // HORIZONTAL SCAN LINE-1
556   {XK_horizlinescan3,              0x23BB},  // HORIZONTAL SCAN LINE-3
557   {XK_horizlinescan5,              0x2500},  // BOX DRAWINGS LIGHT HORIZONTAL
558   {XK_horizlinescan7,              0x23BC},  // HORIZONTAL SCAN LINE-7
559   {XK_horizlinescan9,              0x23BD},  // HORIZONTAL SCAN LINE-9
560   {XK_leftt,                       0x251C},  // BOX DRAWINGS LIGHT VERTICAL AND RIGHT
561   {XK_rightt,                      0x2524},  // BOX DRAWINGS LIGHT VERTICAL AND LEFT
562   {XK_bott,                        0x2534},  // BOX DRAWINGS LIGHT UP AND HORIZONTAL
563   {XK_topt,                        0x252C},  // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
564   {XK_vertbar,                     0x2502},  // BOX DRAWINGS LIGHT VERTICAL
565 
566   // Publishing
567   {XK_emspace,                     0x2003},  // EM SPACE
568   {XK_enspace,                     0x2002},  // EN SPACE
569   {XK_em3space,                    0x2004},  // THREE-PER-EM SPACE
570   {XK_em4space,                    0x2005},  // FOUR-PER-EM SPACE
571   {XK_digitspace,                  0x2007},  // FIGURE SPACE
572   {XK_punctspace,                  0x2008},  // PUNCTUATION SPACE
573   {XK_thinspace,                   0x2009},  // THIN SPACE
574   {XK_hairspace,                   0x200A},  // HAIR SPACE
575   {XK_emdash,                      0x2014},  // EM DASH
576   {XK_endash,                      0x2013},  // EN DASH
577   {XK_signifblank,                 0x2423},  // OPEN BOX
578   {XK_ellipsis,                    0x2026},  // HORIZONTAL ELLIPSIS
579   {XK_doubbaselinedot,             0x2025},  // TWO DOT LEADER
580   {XK_onethird,                    0x2153},  // VULGAR FRACTION ONE THIRD
581   {XK_twothirds,                   0x2154},  // VULGAR FRACTION TWO THIRDS
582   {XK_onefifth,                    0x2155},  // VULGAR FRACTION ONE FIFTH
583   {XK_twofifths,                   0x2156},  // VULGAR FRACTION TWO FIFTHS
584   {XK_threefifths,                 0x2157},  // VULGAR FRACTION THREE FIFTHS
585   {XK_fourfifths,                  0x2158},  // VULGAR FRACTION FOUR FIFTHS
586   {XK_onesixth,                    0x2159},  // VULGAR FRACTION ONE SIXTH
587   {XK_fivesixths,                  0x215A},  // VULGAR FRACTION FIVE SIXTHS
588   {XK_careof,                      0x2105},  // CARE OF
589   {XK_figdash,                     0x2012},  // FIGURE DASH
590   {XK_leftanglebracket,            0x27E8},  // MATHEMATICAL LEFT ANGLE BRACKET
591   {XK_decimalpoint,                0x002E},  // FULL STOP
592   {XK_rightanglebracket,           0x27E9},  // MATHEMATICAL RIGHT ANGLE BRACKET
593   {XK_oneeighth,                   0x215B},  // VULGAR FRACTION ONE EIGHTH
594   {XK_threeeighths,                0x215C},  // VULGAR FRACTION THREE EIGHTHS
595   {XK_fiveeighths,                 0x215D},  // VULGAR FRACTION FIVE EIGHTHS
596   {XK_seveneighths,                0x215E},  // VULGAR FRACTION SEVEN EIGHTHS
597   {XK_trademark,                   0x2122},  // TRADE MARK SIGN
598   {XK_signaturemark,               0x2613},  // SALTIRE
599   {XK_leftopentriangle,            0x25C1},  // WHITE LEFT-POINTING TRIANGLE
600   {XK_rightopentriangle,           0x25B7},  // WHITE RIGHT-POINTING TRIANGLE
601   {XK_emopencircle,                0x25CB},  // WHITE CIRCLE
602   {XK_emopenrectangle,             0x25AF},  // WHITE VERTICAL RECTANGLE
603   {XK_leftsinglequotemark,         0x2018},  // LEFT SINGLE QUOTATION MARK
604   {XK_rightsinglequotemark,        0x2019},  // RIGHT SINGLE QUOTATION MARK
605   {XK_leftdoublequotemark,         0x201C},  // LEFT DOUBLE QUOTATION MARK
606   {XK_rightdoublequotemark,        0x201D},  // RIGHT DOUBLE QUOTATION MARK
607   {XK_prescription,                0x211E},  // PRESCRIPTION TAKE
608   {XK_minutes,                     0x2032},  // PRIME
609   {XK_seconds,                     0x2033},  // DOUBLE PRIME
610   {XK_latincross,                  0x271D},  // LATIN CROSS
611   {XK_filledrectbullet,            0x25AC},  // BLACK RECTANGLE
612   {XK_filledlefttribullet,         0x25C0},  // BLACK LEFT-POINTING TRIANGLE
613   {XK_filledrighttribullet,        0x25B6},  // BLACK RIGHT-POINTING TRIANGLE
614   {XK_emfilledcircle,              0x25CF},  // BLACK CIRCLE
615   {XK_emfilledrect,                0x25AE},  // BLACK VERTICAL RECTANGLE
616   {XK_enopencircbullet,            0x25E6},  // WHITE BULLET
617   {XK_enopensquarebullet,          0x25AB},  // WHITE SMALL SQUARE
618   {XK_openrectbullet,              0x25AD},  // WHITE RECTANGLE
619   {XK_opentribulletup,             0x25B3},  // WHITE UP-POINTING TRIANGLE
620   {XK_opentribulletdown,           0x25BD},  // WHITE DOWN-POINTING TRIANGLE
621   {XK_openstar,                    0x2606},  // WHITE STAR
622   {XK_enfilledcircbullet,          0x2022},  // BULLET
623   {XK_enfilledsqbullet,            0x25AA},  // BLACK SMALL SQUARE
624   {XK_filledtribulletup,           0x25B2},  // BLACK UP-POINTING TRIANGLE
625   {XK_filledtribulletdown,         0x25BC},  // BLACK DOWN-POINTING TRIANGLE
626   {XK_leftpointer,                 0x261C},  // WHITE LEFT POINTING INDEX
627   {XK_rightpointer,                0x261E},  // WHITE RIGHT POINTING INDEX
628   {XK_club,                        0x2663},  // BLACK CLUB SUIT
629   {XK_diamond,                     0x2666},  // BLACK DIAMOND SUIT
630   {XK_heart,                       0x2665},  // BLACK HEART SUIT
631   {XK_maltesecross,                0x2720},  // MALTESE CROSS
632   {XK_dagger,                      0x2020},  // DAGGER
633   {XK_doubledagger,                0x2021},  // DOUBLE DAGGER
634   {XK_checkmark,                   0x2713},  // CHECK MARK
635   {XK_ballotcross,                 0x2717},  // BALLOT X
636   {XK_musicalsharp,                0x266F},  // MUSIC SHARP SIGN
637   {XK_musicalflat,                 0x266D},  // MUSIC FLAT SIGN
638   {XK_malesymbol,                  0x2642},  // MALE SIGN
639   {XK_femalesymbol,                0x2640},  // FEMALE SIGN
640   {XK_telephone,                   0x260E},  // BLACK TELEPHONE
641   {XK_telephonerecorder,           0x2315},  // TELEPHONE RECORDER
642   {XK_phonographcopyright,         0x2117},  // SOUND RECORDING COPYRIGHT
643   {XK_caret,                       0x2038},  // CARET
644   {XK_singlelowquotemark,          0x201A},  // SINGLE LOW-9 QUOTATION MARK
645   {XK_doublelowquotemark,          0x201E},  // DOUBLE LOW-9 QUOTATION MARK
646 
647   // APL
648   {XK_leftcaret,                   0x003C},  // LESS-THAN SIGN
649   {XK_rightcaret,                  0x003E},  // GREATER-THAN SIGN
650   {XK_downcaret,                   0x2228},  // LOGICAL OR
651   {XK_upcaret,                     0x2227},  // LOGICAL AND
652   {XK_overbar,                     0x00AF},  // MACRON
653   {XK_downtack,                    0x22A4},  // DOWN TACK
654   {XK_upshoe,                      0x2229},  // INTERSECTION
655   {XK_downstile,                   0x230A},  // LEFT FLOOR
656   {XK_underbar,                    0x005F},  // LOW LINE
657   {XK_jot,                         0x2218},  // RING OPERATOR
658   {XK_quad,                        0x2395},  // APL FUNCTIONAL SYMBOL QUAD
659   {XK_uptack,                      0x22A5},  // UP TACK
660   {XK_circle,                      0x25CB},  // WHITE CIRCLE
661   {XK_upstile,                     0x2308},  // LEFT CEILING
662   {XK_downshoe,                    0x222A},  // UNION
663   {XK_rightshoe,                   0x2283},  // SUPERSET OF
664   {XK_leftshoe,                    0x2282},  // SUBSET OF
665   {XK_lefttack,                    0x22A3},  // LEFT TACK
666   {XK_righttack,                   0x22A2},  // RIGHT TACK
667 
668   // Hebrew
669   {XK_hebrew_doublelowline,        0x2017},  // DOUBLE LOW LINE
670   {XK_hebrew_aleph,                0x05D0},  // HEBREW LETTER ALEF
671   {XK_hebrew_bet,                  0x05D1},  // HEBREW LETTER BET
672   {XK_hebrew_gimel,                0x05D2},  // HEBREW LETTER GIMEL
673   {XK_hebrew_dalet,                0x05D3},  // HEBREW LETTER DALET
674   {XK_hebrew_he,                   0x05D4},  // HEBREW LETTER HE
675   {XK_hebrew_waw,                  0x05D5},  // HEBREW LETTER VAV
676   {XK_hebrew_zain,                 0x05D6},  // HEBREW LETTER ZAYIN
677   {XK_hebrew_chet,                 0x05D7},  // HEBREW LETTER HET
678   {XK_hebrew_tet,                  0x05D8},  // HEBREW LETTER TET
679   {XK_hebrew_yod,                  0x05D9},  // HEBREW LETTER YOD
680   {XK_hebrew_finalkaph,            0x05DA},  // HEBREW LETTER FINAL KAF
681   {XK_hebrew_kaph,                 0x05DB},  // HEBREW LETTER KAF
682   {XK_hebrew_lamed,                0x05DC},  // HEBREW LETTER LAMED
683   {XK_hebrew_finalmem,             0x05DD},  // HEBREW LETTER FINAL MEM
684   {XK_hebrew_mem,                  0x05DE},  // HEBREW LETTER MEM
685   {XK_hebrew_finalnun,             0x05DF},  // HEBREW LETTER FINAL NUN
686   {XK_hebrew_nun,                  0x05E0},  // HEBREW LETTER NUN
687   {XK_hebrew_samech,               0x05E1},  // HEBREW LETTER SAMEKH
688   {XK_hebrew_ayin,                 0x05E2},  // HEBREW LETTER AYIN
689   {XK_hebrew_finalpe,              0x05E3},  // HEBREW LETTER FINAL PE
690   {XK_hebrew_pe,                   0x05E4},  // HEBREW LETTER PE
691   {XK_hebrew_finalzade,            0x05E5},  // HEBREW LETTER FINAL TSADI
692   {XK_hebrew_zade,                 0x05E6},  // HEBREW LETTER TSADI
693   {XK_hebrew_qoph,                 0x05E7},  // HEBREW LETTER QOF
694   {XK_hebrew_resh,                 0x05E8},  // HEBREW LETTER RESH
695   {XK_hebrew_shin,                 0x05E9},  // HEBREW LETTER SHIN
696   {XK_hebrew_taw,                  0x05EA},  // HEBREW LETTER TAV
697 
698   // Thai
699   {XK_Thai_kokai,                  0x0E01},  // THAI CHARACTER KO KAI
700   {XK_Thai_khokhai,                0x0E02},  // THAI CHARACTER KHO KHAI
701   {XK_Thai_khokhuat,               0x0E03},  // THAI CHARACTER KHO KHUAT
702   {XK_Thai_khokhwai,               0x0E04},  // THAI CHARACTER KHO KHWAI
703   {XK_Thai_khokhon,                0x0E05},  // THAI CHARACTER KHO KHON
704   {XK_Thai_khorakhang,             0x0E06},  // THAI CHARACTER KHO RAKHANG
705   {XK_Thai_ngongu,                 0x0E07},  // THAI CHARACTER NGO NGU
706   {XK_Thai_chochan,                0x0E08},  // THAI CHARACTER CHO CHAN
707   {XK_Thai_choching,               0x0E09},  // THAI CHARACTER CHO CHING
708   {XK_Thai_chochang,               0x0E0A},  // THAI CHARACTER CHO CHANG
709   {XK_Thai_soso,                   0x0E0B},  // THAI CHARACTER SO SO
710   {XK_Thai_chochoe,                0x0E0C},  // THAI CHARACTER CHO CHOE
711   {XK_Thai_yoying,                 0x0E0D},  // THAI CHARACTER YO YING
712   {XK_Thai_dochada,                0x0E0E},  // THAI CHARACTER DO CHADA
713   {XK_Thai_topatak,                0x0E0F},  // THAI CHARACTER TO PATAK
714   {XK_Thai_thothan,                0x0E10},  // THAI CHARACTER THO THAN
715   {XK_Thai_thonangmontho,          0x0E11},  // THAI CHARACTER THO NANGMONTHO
716   {XK_Thai_thophuthao,             0x0E12},  // THAI CHARACTER THO PHUTHAO
717   {XK_Thai_nonen,                  0x0E13},  // THAI CHARACTER NO NEN
718   {XK_Thai_dodek,                  0x0E14},  // THAI CHARACTER DO DEK
719   {XK_Thai_totao,                  0x0E15},  // THAI CHARACTER TO TAO
720   {XK_Thai_thothung,               0x0E16},  // THAI CHARACTER THO THUNG
721   {XK_Thai_thothahan,              0x0E17},  // THAI CHARACTER THO THAHAN
722   {XK_Thai_thothong,               0x0E18},  // THAI CHARACTER THO THONG
723   {XK_Thai_nonu,                   0x0E19},  // THAI CHARACTER NO NU
724   {XK_Thai_bobaimai,               0x0E1A},  // THAI CHARACTER BO BAIMAI
725   {XK_Thai_popla,                  0x0E1B},  // THAI CHARACTER PO PLA
726   {XK_Thai_phophung,               0x0E1C},  // THAI CHARACTER PHO PHUNG
727   {XK_Thai_fofa,                   0x0E1D},  // THAI CHARACTER FO FA
728   {XK_Thai_phophan,                0x0E1E},  // THAI CHARACTER PHO PHAN
729   {XK_Thai_fofan,                  0x0E1F},  // THAI CHARACTER FO FAN
730   {XK_Thai_phosamphao,             0x0E20},  // THAI CHARACTER PHO SAMPHAO
731   {XK_Thai_moma,                   0x0E21},  // THAI CHARACTER MO MA
732   {XK_Thai_yoyak,                  0x0E22},  // THAI CHARACTER YO YAK
733   {XK_Thai_rorua,                  0x0E23},  // THAI CHARACTER RO RUA
734   {XK_Thai_ru,                     0x0E24},  // THAI CHARACTER RU
735   {XK_Thai_loling,                 0x0E25},  // THAI CHARACTER LO LING
736   {XK_Thai_lu,                     0x0E26},  // THAI CHARACTER LU
737   {XK_Thai_wowaen,                 0x0E27},  // THAI CHARACTER WO WAEN
738   {XK_Thai_sosala,                 0x0E28},  // THAI CHARACTER SO SALA
739   {XK_Thai_sorusi,                 0x0E29},  // THAI CHARACTER SO RUSI
740   {XK_Thai_sosua,                  0x0E2A},  // THAI CHARACTER SO SUA
741   {XK_Thai_hohip,                  0x0E2B},  // THAI CHARACTER HO HIP
742   {XK_Thai_lochula,                0x0E2C},  // THAI CHARACTER LO CHULA
743   {XK_Thai_oang,                   0x0E2D},  // THAI CHARACTER O ANG
744   {XK_Thai_honokhuk,               0x0E2E},  // THAI CHARACTER HO NOKHUK
745   {XK_Thai_paiyannoi,              0x0E2F},  // THAI CHARACTER PAIYANNOI
746   {XK_Thai_saraa,                  0x0E30},  // THAI CHARACTER SARA A
747   {XK_Thai_maihanakat,             0x0E31},  // THAI CHARACTER MAI HAN-AKAT
748   {XK_Thai_saraaa,                 0x0E32},  // THAI CHARACTER SARA AA
749   {XK_Thai_saraam,                 0x0E33},  // THAI CHARACTER SARA AM
750   {XK_Thai_sarai,                  0x0E34},  // THAI CHARACTER SARA I
751   {XK_Thai_saraii,                 0x0E35},  // THAI CHARACTER SARA II
752   {XK_Thai_saraue,                 0x0E36},  // THAI CHARACTER SARA UE
753   {XK_Thai_sarauee,                0x0E37},  // THAI CHARACTER SARA UEE
754   {XK_Thai_sarau,                  0x0E38},  // THAI CHARACTER SARA U
755   {XK_Thai_sarauu,                 0x0E39},  // THAI CHARACTER SARA UU
756   {XK_Thai_phinthu,                0x0E3A},  // THAI CHARACTER PHINTHU
757   {XK_Thai_baht,                   0x0E3F},  // THAI CURRENCY SYMBOL BAHT
758   {XK_Thai_sarae,                  0x0E40},  // THAI CHARACTER SARA E
759   {XK_Thai_saraae,                 0x0E41},  // THAI CHARACTER SARA AE
760   {XK_Thai_sarao,                  0x0E42},  // THAI CHARACTER SARA O
761   {XK_Thai_saraaimaimuan,          0x0E43},  // THAI CHARACTER SARA AI MAIMUAN
762   {XK_Thai_saraaimaimalai,         0x0E44},  // THAI CHARACTER SARA AI MAIMALAI
763   {XK_Thai_lakkhangyao,            0x0E45},  // THAI CHARACTER LAKKHANGYAO
764   {XK_Thai_maiyamok,               0x0E46},  // THAI CHARACTER MAIYAMOK
765   {XK_Thai_maitaikhu,              0x0E47},  // THAI CHARACTER MAITAIKHU
766   {XK_Thai_maiek,                  0x0E48},  // THAI CHARACTER MAI EK
767   {XK_Thai_maitho,                 0x0E49},  // THAI CHARACTER MAI THO
768   {XK_Thai_maitri,                 0x0E4A},  // THAI CHARACTER MAI TRI
769   {XK_Thai_maichattawa,            0x0E4B},  // THAI CHARACTER MAI CHATTAWA
770   {XK_Thai_thanthakhat,            0x0E4C},  // THAI CHARACTER THANTHAKHAT
771   {XK_Thai_nikhahit,               0x0E4D},  // THAI CHARACTER NIKHAHIT
772   {XK_Thai_leksun,                 0x0E50},  // THAI DIGIT ZERO
773   {XK_Thai_leknung,                0x0E51},  // THAI DIGIT ONE
774   {XK_Thai_leksong,                0x0E52},  // THAI DIGIT TWO
775   {XK_Thai_leksam,                 0x0E53},  // THAI DIGIT THREE
776   {XK_Thai_leksi,                  0x0E54},  // THAI DIGIT FOUR
777   {XK_Thai_lekha,                  0x0E55},  // THAI DIGIT FIVE
778   {XK_Thai_lekhok,                 0x0E56},  // THAI DIGIT SIX
779   {XK_Thai_lekchet,                0x0E57},  // THAI DIGIT SEVEN
780   {XK_Thai_lekpaet,                0x0E58},  // THAI DIGIT EIGHT
781   {XK_Thai_lekkao,                 0x0E59},  // THAI DIGIT NINE
782 
783   // Korean
784   {XK_Korean_Won,                  0x20A9},  // WON SIGN
785 
786   // Armenian KeySyms map 1:1 to Unicode
787 
788   // Georgian KeySyms map 1:1 to Unicode
789 
790   // Azeri KeySyms map 1:1 to Unicode
791 
792   // Vietnamese KeySyms map 1:1 to Unicode
793 
794   // Currency KeySyms partially map 1:1 to Unicode
795   {XK_EuroSign,                    0x20AC},  // EURO SIGN
796 
797   // Mathematical KeySyms map 1:1 to Unicode
798 
799   // Braille KeySyms map 1:1 to Unicode
800 
801   // Sinhala KeySyms map 1:1 to Unicode
802 };
803 
804 class KeySymToUnicode {
805  public:
KeySymToUnicode()806   KeySymToUnicode()
807       : keysym_to_unicode_map_(arraysize(g_keysym_to_unicode_table)) {
808     for (size_t i = 0; i < arraysize(g_keysym_to_unicode_table); ++i) {
809       keysym_to_unicode_map_[g_keysym_to_unicode_table[i].keysym] =
810           g_keysym_to_unicode_table[i].unicode;
811     }
812   }
813 
UnicodeFromKeySym(KeySym keysym) const814   uint16_t UnicodeFromKeySym(KeySym keysym) const {
815     // Latin-1 characters have the same representation.
816     if ((0x0020 <= keysym && keysym <= 0x007e) ||
817         (0x00a0 <= keysym && keysym <= 0x00ff))
818       return static_cast<uint16_t>(keysym);
819 
820     // Unicode-style KeySyms.
821     if ((keysym & 0xffe00000) == 0x01000000) {
822       uint32_t unicode = static_cast<uint32_t>(keysym & 0x1fffff);
823       if (unicode & ~0xffff)
824         return 0;  // We don't support characters outside the Basic Plane.
825       return static_cast<uint16_t>(unicode);
826     }
827 
828     // Other KeySyms which are not Unicode-style.
829     KeySymToUnicodeMap::const_iterator i =
830         keysym_to_unicode_map_.find(keysym);
831     return i != keysym_to_unicode_map_.end() ? i->second : 0;
832   }
833 
834  private:
835   typedef std::unordered_map<KeySym, uint16_t> KeySymToUnicodeMap;
836   KeySymToUnicodeMap keysym_to_unicode_map_;
837 
838   DISALLOW_COPY_AND_ASSIGN(KeySymToUnicode);
839 };
840 
841 static base::LazyInstance<KeySymToUnicode>::Leaky g_keysym_to_unicode =
842     LAZY_INSTANCE_INITIALIZER;
843 
GetUnicodeCharacterFromXKeySym(unsigned long keysym)844 uint16_t GetUnicodeCharacterFromXKeySym(unsigned long keysym) {
845   return g_keysym_to_unicode.Get().UnicodeFromKeySym(
846       static_cast<KeySym>(keysym));
847 }
848 
849 }  // namespace ui
850