winex11: Bias MapVirtualKeyEx(MAPVK_VSC_TO_VK) against numpad vkeys.
[wine] / tools / wmc / lang.c
1 /*
2  * Wine Message Compiler language and codepage support
3  *
4  * Copyright 2000 Bertho A. Stultiens (BS)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <assert.h>
24
25 #include "wmc.h"
26 #include "lang.h"
27
28
29 /*
30  * Languages supported
31  *
32  * MUST be sorting ascending on language ID
33  */
34 static const language_t languages[] = {
35
36         {0x0000, 437, 1252, "Neutral", NULL},
37         {0x0002, 866, 1251, "Bulgarian", NULL},
38         {0x0003, 850, 1252, "Catalan", NULL},
39         {0x0005, 852, 1250, "Czech", NULL},
40         {0x0006, 850, 1252, "Danish", NULL},
41         {0x0007, 850, 1252, "German", NULL},
42         {0x0008, 737, 1253, "Greek", NULL},
43         {0x0009, 437, 1252, "English", NULL},
44         {0x000A, 850, 1252, "Spanish - Traditional Sort", NULL},
45         {0x000B, 850, 1252, "Finnish", NULL},
46         {0x000C, 850, 1252, "French", NULL},
47         {0x000E, 852, 1250, "Hungarian", NULL},
48         {0x000F, 850, 1252, "Icelandic", NULL},
49         {0x0010, 850, 1252, "Italian", NULL},
50         {0x0011, 932,  932, "Japanese", NULL},
51         {0x0012, 949,  949, "Korean", NULL},
52         {0x0013, 850, 1252, "Dutch", NULL},
53         {0x0014, 850, 1252, "Norwegian (Bokmål)", NULL},
54         {0x0015, 852, 1250, "Polish", NULL},
55         {0x0016, 850, 1252, "Portuguese", NULL},
56         {0x0018, 852, 1250, "Romanian", NULL},
57         {0x0019, 866, 1251, "Russian", NULL},
58         {0x001A, 852, 1250, "Serbian", NULL},
59         {0x001B, 852, 1250, "Slovak", NULL},
60         {0x001C, 852, 1250, "Albanian", NULL},
61         {0x001D, 850, 1252, "Swedish", NULL},
62         {0x001F, 857, 1254, "Turkish", NULL},
63         {0x0021, 850, 1252, "Indonesian", NULL},
64         {0x0022, 866, 1251, "Ukrainian", NULL},
65         {0x0023, 866, 1251, "Belarusian", NULL},
66         {0x0024, 852, 1250, "Slovene", NULL},
67         {0x0025, 775, 1257, "Estonian", NULL},
68         {0x0026, 775, 1257, "Latvian", NULL},
69         {0x0027, 775, 1257, "Lithuanian", NULL},
70         {0x002A,1258, 1258, "Vietnamese", NULL},
71         {0x002D, 850, 1252, "Basque", NULL},
72         {0x002F, 866, 1251, "Macedonian", NULL},
73         {0x0036, 850, 1252, "Afrikaans", NULL},
74         {0x0038, 852, 1252, "Faroese", NULL},
75         {0x003C, 437, 1252, "Irish", NULL},
76         {0x003E, 850, 1252, "Malay", NULL},
77         {0x0402, 866, 1251, "Bulgarian", "Bulgaria"},
78         {0x0403, 850, 1252, "Catalan", "Spain"},
79         {0x0405, 852, 1250, "Czech", "Czech Republic"},
80         {0x0406, 850, 1252, "Danish", "Denmark"},
81         {0x0407, 850, 1252, "German", "Germany"},
82         {0x0408, 737, 1253, "Greek", "Greece"},
83         {0x0409, 437, 1252, "English", "United States"},
84         {0x040A, 850, 1252, "Spanish - Traditional Sort", "Spain"},
85         {0x040B, 850, 1252, "Finnish", "Finland"},
86         {0x040C, 850, 1252, "French", "France"},
87         {0x040E, 852, 1250, "Hungarian", "Hungary"},
88         {0x040F, 850, 1252, "Icelandic", "Iceland"},
89         {0x0410, 850, 1252, "Italian", "Italy"},
90         {0x0411, 932,  932, "Japanese", "Japan"},
91         {0x0412, 949,  949, "Korean", "Korea (south)"},
92         {0x0413, 850, 1252, "Dutch", "Netherlands"},
93         {0x0414, 850, 1252, "Norwegian (Bokmål)", "Norway"},
94         {0x0415, 852, 1250, "Polish", "Poland"},
95         {0x0416, 850, 1252, "Portuguese", "Brazil"},
96         {0x0418, 852, 1250, "Romanian", "Romania"},
97         {0x0419, 866, 1251, "Russian", "Russia"},
98         {0x041A, 852, 1250, "Croatian", "Croatia"},
99         {0x041B, 852, 1250, "Slovak", "Slovakia"},
100         {0x041C, 852, 1250, "Albanian", "Albania"},
101         {0x041D, 850, 1252, "Swedish", "Sweden"},
102         {0x041F, 857, 1254, "Turkish", "Turkey"},
103         {0x0421, 850, 1252, "Indonesian", "Indonesia"},
104         {0x0422, 866, 1251, "Ukrainian", "Ukraine"},
105         {0x0423, 866, 1251, "Belarusian", "Belarus"},
106         {0x0424, 852, 1250, "Slovene", "Slovenia"},
107         {0x0425, 775, 1257, "Estonian", "Estonia"},
108         {0x0426, 775, 1257, "Latvian", "Latvia"},
109         {0x0427, 775, 1257, "Lithuanian", "Lithuania"},
110         {0x042A,1258, 1258, "Vietnamese", "Vietnam"},
111         {0x042D, 850, 1252, "Basque", "Spain"},
112         {0x042F, 866, 1251, "Macedonian", "Former Yugoslav Republic of Macedonia"},
113         {0x0436, 850, 1252, "Afrikaans", "South Africa"},
114         {0x0438, 852, 1252, "Faroese", "Faroe Islands"},
115         {0x043C, 437, 1252, "Irish", "Ireland"},
116         {0x043E, 850, 1252, "Malay", "Malaysia"},
117 /*      {0x048F,   ?,    ?, "Esperanto", "<none>"},*/
118         {0x0804, 936,  936, "Chinese (People's republic of China)", "People's republic of China"},
119         {0x0807, 850, 1252, "German", "Switzerland"},
120         {0x0809, 850, 1252, "English", "United Kingdom"},
121         {0x080A, 850, 1252, "Spanish", "Mexico"},
122         {0x080C, 850, 1252, "French", "Belgium"},
123         {0x0810, 850, 1252, "Italian", "Switzerland"},
124         {0x0813, 850, 1252, "Dutch", "Belgium"},
125         {0x0814, 850, 1252, "Norwegian (Nynorsk)", "Norway"},
126         {0x0816, 850, 1252, "Portuguese", "Portugal"},
127         {0x081A, 852, 1250, "Serbian (latin)", "Yugoslavia"},
128         {0x081D, 850, 1252, "Swedish (Finland)", "Finland"},
129         {0x0C07, 850, 1252, "German", "Austria"},
130         {0x0C09, 850, 1252, "English", "Australia"},
131         {0x0C0A, 850, 1252, "Spanish - International Sort", "Spain"},
132         {0x0C0C, 850, 1252, "French", "Canada"},
133         {0x0C1A, 855, 1251, "Serbian (Cyrillic)", "Serbia"},
134         {0x1007, 850, 1252, "German", "Luxembourg"},
135         {0x1009, 850, 1252, "English", "Canada"},
136         {0x100A, 850, 1252, "Spanish", "Guatemala"},
137         {0x100C, 850, 1252, "French", "Switzerland"},
138         {0x1407, 850, 1252, "German", "Liechtenstein"},
139         {0x1409, 850, 1252, "English", "New Zealand"},
140         {0x140A, 850, 1252, "Spanish", "Costa Rica"},
141         {0x140C, 850, 1252, "French", "Luxembourg"},
142         {0x1809, 850, 1252, "English", "Ireland"},
143         {0x180A, 850, 1252, "Spanish", "Panama"},
144         {0x1C09, 437, 1252, "English", "South Africa"},
145         {0x1C0A, 850, 1252, "Spanish", "Dominican Republic"},
146         {0x2009, 850, 1252, "English", "Jamaica"},
147         {0x200A, 850, 1252, "Spanish", "Venezuela"},
148         {0x2409, 850, 1252, "English", "Caribbean"},
149         {0x240A, 850, 1252, "Spanish", "Colombia"},
150         {0x2809, 850, 1252, "English", "Belize"},
151         {0x280A, 850, 1252, "Spanish", "Peru"},
152         {0x2C09, 437, 1252, "English", "Trinidad & Tobago"},
153         {0x2C0A, 850, 1252, "Spanish", "Argentina"},
154         {0x300A, 850, 1252, "Spanish", "Ecuador"},
155         {0x340A, 850, 1252, "Spanish", "Chile"},
156         {0x380A, 850, 1252, "Spanish", "Uruguay"},
157         {0x3C0A, 850, 1252, "Spanish", "Paraguay"},
158         {0x400A, 850, 1252, "Spanish", "Bolivia"},
159         {0x440A, 850, 1252, "Spanish", "El Salvador"},
160         {0x480A, 850, 1252, "Spanish", "Honduras"},
161         {0x4C0A, 850, 1252, "Spanish", "Nicaragua"},
162         {0x500A, 850, 1252, "Spanish", "Puerto Rico"}
163 };
164
165 #define NLAN    (sizeof(languages)/sizeof(languages[0]))
166
167 void show_languages(void)
168 {
169         unsigned int i;
170         printf(" Code  | DOS-cp | WIN-cp |   Language   | Country\n");
171         printf("-------+--------+--------+--------------+---------\n");
172         for(i = 0; i < NLAN; i++)
173                 printf("0x%04x | %5d  | %5d   | %-12s | %s\n",
174                         languages[i].id,
175                         languages[i].doscp,
176                         languages[i].wincp,
177                         languages[i].name,
178                         languages[i].country ? languages[i].country : "Neutral");
179 }
180
181 static int langcmp(const void *p1, const void *p2)
182 {
183         return *(const unsigned *)p1 - ((const language_t *)p2)->id;
184 }
185
186 const language_t *find_language(unsigned id)
187 {
188         return (const language_t *)bsearch(&id, languages, NLAN, sizeof(languages[0]), langcmp);
189 }
190
191 void show_codepages(void)
192 {
193         unsigned i;
194         const union cptable *cpp;
195         printf("Codepages:\n");
196         for(i = 0; (cpp = wine_cp_enum_table(i)); i++)
197         {
198                 printf("%-5d %s\n", cpp->info.codepage, cpp->info.name);
199         }
200 }
201
202 const union cptable *find_codepage(int id)
203 {
204         return wine_cp_get_table(id);
205 }