2 // System.Globalization.CultureInfo
4 // Miguel de Icaza (miguel@ximian.com)
5 // Dick Porter (dick@ximian.com)
7 // (C) 2001, 2002, 2003 Ximian, Inc. (http://www.ximian.com)
10 using System.Collections;
11 using System.Threading;
12 using System.Runtime.CompilerServices;
14 namespace System.Globalization
17 public class CultureInfo : ICloneable, IFormatProvider
19 static CultureInfo invariant_culture_info;
22 bool use_user_override;
23 NumberFormatInfo number_format;
24 DateTimeFormatInfo datetime_format;
28 private string displayname;
29 private string englishname;
30 private string nativename;
31 private string iso3lang;
32 private string iso2lang;
33 private string icu_name;
34 private string win3lang;
35 private CompareInfo compareinfo;
37 private static readonly string MSG_READONLY = "This instance is read only";
39 internal sealed class CultureMap : IEnumerable
41 private static Hashtable CultureID;
42 private static Hashtable CultureNames;
44 /* This is used so that foreach can enumerate
45 * the ID map hash without having to
46 * instantiate an instance itself
48 public static CultureMap lcids;
51 private string icu_name;
52 private string win3lang;
54 private int specific_lcid;
55 private int parent_lcid;
59 CultureID=new Hashtable (CaseInsensitiveHashCodeProvider.Default, new CaseInsensitiveComparer (CultureInfo.InvariantCulture));
60 CultureNames=new Hashtable (CaseInsensitiveHashCodeProvider.Default, new CaseInsensitiveComparer (CultureInfo.InvariantCulture));
65 map=new CultureMap ("", "en_US_POSIX", "IVL", 0x007f, 0x007f, 0x007f);
66 CultureID.Add (0x007f, map);
67 CultureNames.Add ("", map);
69 map=new CultureMap ("af", "af", "AFK", 0x0036, 0x0436, 0x007f);
70 CultureID.Add (0x0036, map);
71 CultureNames.Add ("af", map);
73 map=new CultureMap ("af-ZA", "af_ZA", "AFK", 0x0436, 0x0436, 0x0036);
74 CultureID.Add (0x0436, map);
75 CultureNames.Add ("af-ZA", map);
77 map=new CultureMap("sq", "sq", "SQI", 0x001c, 0x041c, 0x007f);
78 CultureID.Add (0x001c, map);
79 CultureNames.Add ("sq", map);
81 map=new CultureMap("sq-AL", "sq_AL", "SQI", 0x041c, 0x041c, 0x001c);
82 CultureID.Add (0x041c, map);
83 CultureNames.Add ("sq-AL", map);
85 map=new CultureMap("ar", "ar", "ARA", 0x0001, 0x0401, 0x007f);
86 CultureID.Add (0x0001, map);
87 CultureNames.Add ("ar", map);
89 map=new CultureMap("ar-DZ", "ar_DZ", "ARG", 0x1401, 0x1401, 0x0001);
90 CultureID.Add (0x1401, map);
91 CultureNames.Add ("ar-DZ", map);
93 map=new CultureMap("ar-BH", "ar_BH", "ARH", 0x3c01, 0x3c01, 0x0001);
94 CultureID.Add (0x3c01, map);
95 CultureNames.Add ("ar-BH", map);
97 map=new CultureMap("ar-EG", "ar_EG", "ARE", 0x0c01, 0x0c01, 0x0001);
98 CultureID.Add (0x0c01, map);
99 CultureNames.Add ("ar-EG", map);
101 map=new CultureMap("ar-IQ", "ar_IQ", "ARI", 0x0801, 0x0801, 0x0001);
102 CultureID.Add (0x0801, map);
103 CultureNames.Add ("ar-IQ", map);
105 map=new CultureMap("ar-JO", "ar_JO", "ARJ", 0x2c01, 0x2c01, 0x0001);
106 CultureID.Add (0x2c01, map);
107 CultureNames.Add ("ar-JO", map);
109 map=new CultureMap("ar-KW", "ar_KW", "ARK", 0x3401, 0x3401, 0x0001);
110 CultureID.Add (0x3401, map);
111 CultureNames.Add ("ar-KW", map);
113 map=new CultureMap("ar-LB", "ar_LB", "ARB", 0x3001, 0x3001, 0x0001);
114 CultureID.Add (0x3001, map);
115 CultureNames.Add ("ar-LB", map);
117 map=new CultureMap("ar-LY", "ar_LY", "ARL", 0x1001, 0x1001, 0x0001);
118 CultureID.Add (0x1001, map);
119 CultureNames.Add ("ar-LY", map);
121 map=new CultureMap("ar-MA", "ar_MA", "ARM", 0x1801, 0x1801, 0x0001);
122 CultureID.Add (0x1801, map);
123 CultureNames.Add ("ar-MA", map);
125 map=new CultureMap("ar-OM", "ar_OM", "ARO", 0x2001, 0x2001, 0x0001);
126 CultureID.Add (0x2001, map);
127 CultureNames.Add ("ar-OM", map);
129 map=new CultureMap("ar-QA", "ar_QA", "ARQ", 0x4001, 0x4001, 0x0001);
130 CultureID.Add (0x4001, map);
131 CultureNames.Add ("ar-QA", map);
133 map=new CultureMap("ar-SA", "ar_SA", "ARA", 0x0401, 0x0401, 0x0001);
134 CultureID.Add (0x0401, map);
135 CultureNames.Add ("ar-SA", map);
137 map=new CultureMap("ar-SY", "ar_SY", "ARS", 0x2801, 0x2801, 0x0001);
138 CultureID.Add (0x2801, map);
139 CultureNames.Add ("ar-SY", map);
141 map=new CultureMap("ar-TN", "ar_TN", "ART", 0x1c01, 0x1c01, 0x0001);
142 CultureID.Add (0x1c01, map);
143 CultureNames.Add ("ar-TN", map);
145 map=new CultureMap("ar-AE", "ar_AE", "ARU", 0x3801, 0x3801, 0x0001);
146 CultureID.Add (0x3801, map);
147 CultureNames.Add ("ar-AE", map);
149 map=new CultureMap("ar-YE", "ar_YE", "ARY", 0x2401, 0x2401, 0x0001);
150 CultureID.Add (0x2401, map);
151 CultureNames.Add ("ar-YE", map);
153 map=new CultureMap("hy", "hy", "HYE", 0x002b, 0x042b, 0x007f);
154 CultureID.Add (0x002b, map);
155 CultureNames.Add ("hy", map);
157 /* theres a _REVISED version of this one too */
158 map=new CultureMap("hy-AM", "hy_AM", "HYE", 0x042b, 0x042b, 0x002b);
159 CultureID.Add (0x042b, map);
160 CultureNames.Add ("hy-AM", map);
162 /* Azeri not supported
163 map=new CultureMap("az", "", "AZE", 0x002c, 0x042c, 0x007f);
164 CultureID.Add (0x002c, map);
165 CultureNames.Add ("az", map);
167 map=new CultureMap("Cy-az-AZ", "", "AZE", 0x082c, 0x082c, 0x002c);
168 CultureID.Add (0x082c, map);
169 CultureNames.Add ("Cy-az-AZ", map);
171 map=new CultureMap("Lt-az-AZ", "", "AZE", 0x042c, 0x042c);
172 CultureID.Add (0x042c, map);
173 CultureNames.Add ("Lt-az-AZ", map);*/
175 map=new CultureMap("eu", "eu", "EUQ", 0x002d, 0x042d, 0x007f);
176 CultureID.Add (0x002d, map);
177 CultureNames.Add ("eu", map);
179 map=new CultureMap("eu-ES", "eu_ES", "EUQ", 0x042d, 0x042d, 0x002d);
180 CultureID.Add (0x042d, map);
181 CultureNames.Add ("eu-ES", map);
183 map=new CultureMap("be", "be", "BEL", 0x0023, 0x0423, 0x007f);
184 CultureID.Add (0x0023, map);
185 CultureNames.Add ("be", map);
187 map=new CultureMap("be-BY", "be_BY", "BEL", 0x0423, 0x0423, 0x0023);
188 CultureID.Add (0x0423, map);
189 CultureNames.Add ("be-BY", map);
191 map=new CultureMap("bg", "bg", "BGR", 0x0002, 0x0402, 0x007f);
192 CultureID.Add (0x0002, map);
193 CultureNames.Add ("bg", map);
195 map=new CultureMap("bg-BG", "bg_BG", "BGR", 0x0402, 0x0402, 0x0002);
196 CultureID.Add (0x0402, map);
197 CultureNames.Add ("bg-BG", map);
199 map=new CultureMap("ca", "ca", "CAT", 0x0003, 0x0403, 0x007f);
200 CultureID.Add (0x0003, map);
201 CultureNames.Add ("ca", map);
203 map=new CultureMap("ca-ES", "ca_ES", "CAT", 0x0403, 0x0403, 0x0003);
204 CultureID.Add (0x0403, map);
205 CultureNames.Add ("ca-ES", map);
207 map=new CultureMap("zh-HK", "zh_HK", "ZHH", 0x0c04, 0x0c04, 0x7c04);
208 CultureID.Add (0x0c04, map);
209 CultureNames.Add ("zh-HK", map);
211 map=new CultureMap("zh-MO", "zh_MO", "ZHM", 0x1404, 0x1404, 0x0004);
212 CultureID.Add (0x1404, map);
213 CultureNames.Add ("zh-MO", map);
215 map=new CultureMap("zh-CN", "zh_CN", "CHS", 0x0804, 0x0804, 0x0004);
216 CultureID.Add (0x0804, map);
217 CultureNames.Add ("zh-CN", map);
219 /* zh-CHS (Chinese simplified). 'zh' is LCID 0x0004 in ICU */
220 map=new CultureMap("zh-CHS", "zh", "CHS", 0x0004, 0x0000, 0x007f);
221 CultureID.Add (0x0004, map);
222 CultureNames.Add ("zh-CHS", map);
224 map=new CultureMap("zh-SG", "zh_SG", "ZHI", 0x1004, 0x1004, 0x0004);
225 CultureID.Add (0x1004, map);
226 CultureNames.Add ("zh-SG", map);
228 map=new CultureMap("zh-TW", "zh_TW", "CHT", 0x0404, 0x0404, 0x7c04);
229 CultureID.Add (0x0404, map);
230 CultureNames.Add ("zh-TW", map);
232 /* zh-CHT (Chinese traditional). Maybe set this to zh_TW? (politics, politics...) */
233 map=new CultureMap("zh-CHT", "zh_TW", "CHT", 0x7c04, 0x0000, 0x007f);
234 CultureID.Add (0x7c04, map);
235 CultureNames.Add ("zh-CHT", map);
237 map=new CultureMap("hr", "hr", "HRV", 0x001a, 0x041a, 0x007f);
238 CultureID.Add (0x001a, map);
239 CultureNames.Add ("hr", map);
241 map=new CultureMap("hr-HR", "hr_HR", "HRV", 0x041a, 0x041a, 0x001a);
242 CultureID.Add (0x041a, map);
243 CultureNames.Add ("hr-HR", map);
245 map=new CultureMap("cs", "cs", "CSY", 0x0005, 0x0405, 0x007f);
246 CultureID.Add (0x0005, map);
247 CultureNames.Add ("cs", map);
249 map=new CultureMap("cs-CZ", "cs_CZ", "CSY", 0x0405, 0x0405, 0x0005);
250 CultureID.Add (0x0405, map);
251 CultureNames.Add ("cs-CZ", map);
253 map=new CultureMap("da", "da", "DAN", 0x0006, 0x0406, 0x007f);
254 CultureID.Add (0x0006, map);
255 CultureNames.Add ("da", map);
257 map=new CultureMap("da-DK", "da_DK", "DAN", 0x0406, 0x0406, 0x0006);
258 CultureID.Add (0x0406, map);
259 CultureNames.Add ("da-DK", map);
261 /* Dhivehi not supported
262 map=new CultureMap("div", "", "DIV", 0x0065, 0x0465, 0x007f);
263 CultureID.Add (0x0065, map);
264 CultureNames.Add ("div", map);
266 map=new CultureMap("div-MV", "", "DIV", 0x0465, 0x0465, 0x0065);
267 CultureID.Add (0x0465, map);
268 CultureNames.Add ("div-MV", map);*/
270 map=new CultureMap("nl", "nl", "NLD", 0x0013, 0x0413, 0x007f);
271 CultureID.Add (0x0013, map);
272 CultureNames.Add ("nl", map);
274 map=new CultureMap("nl-BE", "nl_BE", "NLB", 0x0813, 0x0813, 0x0013);
275 CultureID.Add (0x0813, map);
276 CultureNames.Add ("nl-BE", map);
278 map=new CultureMap("nl-NL", "nl_NL", "NLD", 0x0413, 0x0413, 0x0013);
279 CultureID.Add (0x0413, map);
280 CultureNames.Add ("nl-NL", map);
282 map=new CultureMap("en", "en", "ENU", 0x0009, 0x0409, 0x007f);
283 CultureID.Add (0x0009, map);
284 CultureNames.Add ("en", map);
286 map=new CultureMap("en-AU", "en_AU", "ENA", 0x0c09, 0x0c09, 0x0009);
287 CultureID.Add (0x0c09, map);
288 CultureNames.Add ("en-AU", map);
290 /* Falls back to 'en' currently */
291 map=new CultureMap("en-BZ", "en_BZ", "ENL", 0x2809, 0x2809, 0x0009);
292 CultureID.Add (0x2809, map);
293 CultureNames.Add ("en-BZ", map);
295 map=new CultureMap("en-CA", "en_CA", "ENC", 0x1009, 0x1009, 0x0009);
296 CultureID.Add (0x1009, map);
297 CultureNames.Add ("en-CA", map);
299 /* ms calls this en-CB but ICU has this ID as Virgin Islands */
300 map=new CultureMap("en-CB", "en_VI", "ENB", 0x2409, 0x2409, 0x0009);
301 CultureID.Add (0x2409, map);
302 CultureNames.Add ("en-CB", map);
304 map=new CultureMap("en-IE", "en_IE", "ENI", 0x1809, 0x1809, 0x0009);
305 CultureID.Add (0x1809, map);
306 CultureNames.Add ("en-IE", map);
308 /* Falls back to 'en' currently */
309 map=new CultureMap("en-JM", "en_JM", "ENJ", 0x2009, 0x2009, 0x0009);
310 CultureID.Add (0x2009, map);
311 CultureNames.Add ("en-JM", map);
313 map=new CultureMap("en-NZ", "en_NZ", "ENZ", 0x1409, 0x1409, 0x0009);
314 CultureID.Add (0x1409, map);
315 CultureNames.Add ("en-NZ", map);
317 map=new CultureMap("en-PH", "en_PH", "ENP", 0x3409, 0x3409, 0x0009);
318 CultureID.Add (0x3409, map);
319 CultureNames.Add ("en-PH", map);
321 map=new CultureMap("en-ZA", "en_ZA", "ENS", 0x1c09, 0x1c09, 0x0009);
322 CultureID.Add (0x1c09, map);
323 CultureNames.Add ("en-ZA", map);
325 /* Falls back to 'en' currently */
326 map=new CultureMap("en-TT", "en_TT", "ENT", 0x2c09, 0x2c09, 0x0009);
327 CultureID.Add (0x2c09, map);
328 CultureNames.Add ("en-TT", map);
330 map=new CultureMap("en-GB", "en_GB", "ENG", 0x0809, 0x0809, 0x0009);
331 CultureID.Add (0x0809, map);
332 CultureNames.Add ("en-GB", map);
334 map=new CultureMap("en-US", "en_US", "ENU", 0x0409, 0x0409, 0x0009);
335 CultureID.Add (0x0409, map);
336 CultureNames.Add ("en-US", map);
338 map=new CultureMap("en-ZW", "en_ZW", "ENW", 0x3009, 0x3009, 0x0009);
339 CultureID.Add (0x3009, map);
340 CultureNames.Add ("en-ZW", map);
342 map=new CultureMap("et", "et", "ETI", 0x0025, 0x0425, 0x007f);
343 CultureID.Add (0x0025, map);
344 CultureNames.Add ("et", map);
346 map=new CultureMap("et-EE", "et_EE", "ETI", 0x0425, 0x0425, 0x0025);
347 CultureID.Add (0x0425, map);
348 CultureNames.Add ("et-EE", map);
350 map=new CultureMap("fo", "fo", "FOS", 0x0038, 0x0438, 0x007f);
351 CultureID.Add (0x0038, map);
352 CultureNames.Add ("fo", map);
354 map=new CultureMap("fo-FO", "fo_FO", "FOS", 0x0438, 0x0438, 0x0038);
355 CultureID.Add (0x0438, map);
356 CultureNames.Add ("fo-FO", map);
358 map=new CultureMap("fa", "fa", "FAR", 0x0029, 0x0429, 0x007f);
359 CultureID.Add (0x0029, map);
360 CultureNames.Add ("fa", map);
362 map=new CultureMap("fa-IR", "fa_IR", "FAR", 0x0429, 0x0429, 0x0029);
363 CultureID.Add (0x0429, map);
364 CultureNames.Add ("fa-IR", map);
366 map=new CultureMap("fi", "fi", "FIN", 0x000b, 0x040b, 0x007f);
367 CultureID.Add (0x000b, map);
368 CultureNames.Add ("fi", map);
370 map=new CultureMap("fi-FI", "fi_FI", "FIN", 0x040b, 0x040b, 0x000b);
371 CultureID.Add (0x040b, map);
372 CultureNames.Add ("fi-FI", map);
374 map=new CultureMap("fr", "fr", "FRA", 0x000c, 0x040c, 0x007f);
375 CultureID.Add (0x000c, map);
376 CultureNames.Add ("fr", map);
378 map=new CultureMap("fr-BE", "fr_BE", "FRB", 0x080c, 0x080c, 0x000c);
379 CultureID.Add (0x080c, map);
380 CultureNames.Add ("fr-BE", map);
382 map=new CultureMap("fr-CA", "fr_CA", "FRC", 0x0c0c, 0x0c0c, 0x000c);
383 CultureID.Add (0x0c0c, map);
384 CultureNames.Add ("fr-CA", map);
386 map=new CultureMap("fr-FR", "fr_FR", "FRA", 0x040c, 0x040c, 0x000c);
387 CultureID.Add (0x040c, map);
388 CultureNames.Add ("fr-FR", map);
390 map=new CultureMap("fr-LU", "fr_LU", "FRL", 0x140c, 0x140c, 0x000c);
391 CultureID.Add (0x140c, map);
392 CultureNames.Add ("fr-LU", map);
394 /* Falls back to 'fr' currently */
395 map=new CultureMap("fr-MC", "fr_MC", "FRM", 0x180c, 0x180c, 0x000c);
396 CultureID.Add (0x180c, map);
397 CultureNames.Add ("fr-MC", map);
399 map=new CultureMap("fr-CH", "fr_CH", "FRS", 0x100c, 0x100c, 0x000c);
400 CultureID.Add (0x100c, map);
401 CultureNames.Add ("fr-CH", map);
403 map=new CultureMap("gl", "gl", "GLC", 0x0056, 0x0456, 0x007f);
404 CultureID.Add (0x0056, map);
405 CultureNames.Add ("gl", map);
407 map=new CultureMap("gl-ES", "gl_ES", "GLC", 0x0456, 0x0456, 0x0056);
408 CultureID.Add (0x0456, map);
409 CultureNames.Add ("gl-ES", map);
411 /* Georgian not supported
412 map=new CultureMap("ka", "", "KAT", 0x0037, 0x0437, 0x007f);
413 CultureID.Add (0x0037, map);
414 CultureNames.Add ("ka", map);
416 map=new CultureMap("ka-GE", "", "KAT", 0x0437, 0x0437, 0x0037);
417 CultureID.Add (0x0437, map);
418 CultureNames.Add ("ka-GE", map);*/
420 map=new CultureMap("de", "de", "DEU", 0x0007, 0x0407, 0x007f);
421 CultureID.Add (0x0007, map);
422 CultureNames.Add ("de", map);
424 map=new CultureMap("de-AT", "de_AT", "DEA", 0x0c07, 0x0c07, 0x0007);
425 CultureID.Add (0x0c07, map);
426 CultureNames.Add ("de-AT", map);
428 map=new CultureMap("de-DE", "de_DE", "DEU", 0x0407, 0x0407, 0x0007);
429 CultureID.Add (0x0407, map);
430 CultureNames.Add ("de-DE", map);
432 /* Falls back to 'de' currently */
433 map=new CultureMap("de-LI", "de_LI", "DEC", 0x1407, 0x1407, 0x0007);
434 CultureID.Add (0x1407, map);
435 CultureNames.Add ("de-LI", map);
437 map=new CultureMap("de-LU", "de_LU", "DEL", 0x1007, 0x1007, 0x0007);
438 CultureID.Add (0x1007, map);
439 CultureNames.Add ("de-LU", map);
441 map=new CultureMap("de-CH", "de_CH", "DES", 0x0807, 0x0807, 0x0007);
442 CultureID.Add (0x0807, map);
443 CultureNames.Add ("de-CH", map);
445 map=new CultureMap("el", "el", "ELL", 0x0008, 0x0408, 0x007f);
446 CultureID.Add (0x0008, map);
447 CultureNames.Add ("el", map);
449 map=new CultureMap("el-GR", "el_GR", "ELL", 0x0408, 0x0408, 0x0008);
450 CultureID.Add (0x0408, map);
451 CultureNames.Add ("el-GR", map);
453 map=new CultureMap("gu", "gu", "GUJ", 0x0047, 0x0447, 0x007f);
454 CultureID.Add (0x0047, map);
455 CultureNames.Add ("gu", map);
457 map=new CultureMap("gu-IN", "gu_IN", "GUJ", 0x0447, 0x0447, 0x0047);
458 CultureID.Add (0x0447, map);
459 CultureNames.Add ("gu-IN", map);
461 map=new CultureMap("he", "he", "HEB", 0x000d, 0x040d, 0x007f);
462 CultureID.Add (0x000d, map);
463 CultureNames.Add ("he", map);
465 map=new CultureMap("he-IL", "he_IL", "HEB", 0x040d, 0x040d, 0x000d);
466 CultureID.Add (0x040d, map);
467 CultureNames.Add ("he-IL", map);
469 map=new CultureMap("hi", "hi", "HIN", 0x0039, 0x0439, 0x007f);
470 CultureID.Add (0x0039, map);
471 CultureNames.Add ("hi", map);
473 map=new CultureMap("hi-IN", "hi_IN", "HIN", 0x0439, 0x0439, 0x0039);
474 CultureID.Add (0x0439, map);
475 CultureNames.Add ("hi-IN", map);
477 map=new CultureMap("hu", "hu", "HUN", 0x000e, 0x040e, 0x007f);
478 CultureID.Add (0x000e, map);
479 CultureNames.Add ("hu", map);
481 map=new CultureMap("hu-HU", "hu_HU", "HUN", 0x040e, 0x040e, 0x000e);
482 CultureID.Add (0x040e, map);
483 CultureNames.Add ("hu-HU", map);
485 map=new CultureMap("is", "is", "ISL", 0x000f, 0x040f, 0x007f);
486 CultureID.Add (0x000f, map);
487 CultureNames.Add ("is", map);
489 map=new CultureMap("is-IS", "is_IS", "ISL", 0x040f, 0x040f, 0x000f);
490 CultureID.Add (0x040f, map);
491 CultureNames.Add ("is-IS", map);
493 map=new CultureMap("id", "id", "IND", 0x0021, 0x0421, 0x007f);
494 CultureID.Add (0x0021, map);
495 CultureNames.Add ("id", map);
497 map=new CultureMap("id-ID", "id_ID", "IND", 0x0421, 0x0421, 0x0021);
498 CultureID.Add (0x0421, map);
499 CultureNames.Add ("id-ID", map);
501 map=new CultureMap("it", "it", "ITA", 0x0010, 0x0410, 0x007f);
502 CultureID.Add (0x0010, map);
503 CultureNames.Add ("it", map);
505 map=new CultureMap("it-IT", "it_IT", "ITA", 0x0410, 0x0410, 0x0010);
506 CultureID.Add (0x0410, map);
507 CultureNames.Add ("it-IT", map);
509 map=new CultureMap("it-CH", "it_CH", "ITS", 0x0810, 0x0810, 0x0010);
510 CultureID.Add (0x0810, map);
511 CultureNames.Add ("it-CH", map);
513 map=new CultureMap("ja", "ja", "JPN", 0x0011, 0x0411, 0x007f);
514 CultureID.Add (0x0011, map);
515 CultureNames.Add ("ja", map);
517 map=new CultureMap("ja-JP", "ja_JP", "JPN", 0x0411, 0x0411, 0x0011);
518 CultureID.Add (0x0411, map);
519 CultureNames.Add ("ja-JP", map);
521 map=new CultureMap("kn", "kn", "KAN", 0x004b, 0x044b, 0x007f);
522 CultureID.Add (0x004b, map);
523 CultureNames.Add ("kn", map);
525 map=new CultureMap("kn-IN", "kn_IN", "KAN", 0x044b, 0x044b, 0x004b);
526 CultureID.Add (0x044b, map);
527 CultureNames.Add ("kn-IN", map);
529 /* Kazakh not supported
530 map=new CultureMap("kk", "kk", "KKZ", 0x003f, 0x043f, 0x007f);
531 CultureID.Add (0x003f, map);
532 CultureNames.Add ("kk", map);
534 map=new CultureMap("kk-KZ", "kk-KZ", "KKZ", 0x043f, 0x043f, 0x003f);
535 CultureID.Add (0x043f, map);
536 CultureNames.Add ("kk-KZ", map);*/
538 map=new CultureMap("kok", "kok", "KNK", 0x0057, 0x0457, 0x007f);
539 CultureID.Add (0x0057, map);
540 CultureNames.Add ("kok", map);
542 map=new CultureMap("kok-IN", "kok_IN", "KNK", 0x0457, 0x0457, 0x0057);
543 CultureID.Add (0x0457, map);
544 CultureNames.Add ("kok-IN", map);
546 map=new CultureMap("ko", "ko", "KOR", 0x0012, 0x0412, 0x007f);
547 CultureID.Add (0x0012, map);
548 CultureNames.Add ("ko", map);
550 map=new CultureMap("ko-KR", "ko_KR", "KOR", 0x0412, 0x0412, 0x0012);
551 CultureID.Add (0x0412, map);
552 CultureNames.Add ("ko-KR", map);
554 /* Kyrgyz not supported
555 map=new CultureMap("ky", "ky", "KYR", 0x0040, 0x0440, 0x007f);
556 CultureID.Add (0x0040, map);
557 CultureNames.Add ("ky", map);
559 map=new CultureMap("ky-KZ", "ky-KZ", "KYR", 0x0440, 0x0440, 0x0040);
560 CultureID.Add (0x0440, map);
561 CultureNames.Add ("ky-KZ", map);*/
563 map=new CultureMap("lv", "lv", "LVI", 0x0026, 0x0426, 0x007f);
564 CultureID.Add (0x0026, map);
565 CultureNames.Add ("lv", map);
567 map=new CultureMap("lv-LV", "lv_LV", "LVI", 0x0426, 0x0426, 0x0026);
568 CultureID.Add (0x0426, map);
569 CultureNames.Add ("lv-LV", map);
571 map=new CultureMap("lt", "lt", "LTH", 0x0027, 0x0427, 0x007f);
572 CultureID.Add (0x0027, map);
573 CultureNames.Add ("lt", map);
575 map=new CultureMap("lt-LT", "lt_LT", "LTH", 0x0427, 0x0427, 0x0027);
576 CultureID.Add (0x0427, map);
577 CultureNames.Add ("lt-LT", map);
579 map=new CultureMap("mk", "mk", "MKI", 0x002f, 0x042f, 0x007f);
580 CultureID.Add (0x002f, map);
581 CultureNames.Add ("mk", map);
583 map=new CultureMap("mk-MK", "mk_MK", "MKI", 0x042f, 0x042f, 0x002f);
584 CultureID.Add (0x042f, map);
585 CultureNames.Add ("mk-MK", map);
587 /* Malay not supported
588 map=new CultureMap("ms", "ms", "MSL", 0x003e, 0x043e, 0x007f);
589 CultureID.Add (0x003e, map);
590 CultureNames.Add ("ms", map);
592 map=new CultureMap("ms-BN", "ms-BN", "MSB", 0x083e, 0x083e, 0x003e);
593 CultureID.Add (0x083e, map);
594 CultureNames.Add ("ms-BN", map);
596 map=new CultureMap("ms-MY", "ms-MY", "MSL", 0x043e, 0x043e, 0x003e);
597 CultureID.Add (0x043e, map);
598 CultureNames.Add ("ms-MY", map);*/
600 map=new CultureMap("mr", "mr", "MAR", 0x004e, 0x044e, 0x007f);
601 CultureID.Add (0x004e, map);
602 CultureNames.Add ("mr", map);
604 map=new CultureMap("mr-IN", "mr_IN", "MAR", 0x044e, 0x044e, 0x004e);
605 CultureID.Add (0x044e, map);
606 CultureNames.Add ("mr-IN", map);
608 /* Mongolian not supported
609 map=new CultureMap("mn", "mn", "MON", 0x0050, 0x0450, 0x007f);
610 CultureID.Add (0x0050, map);
611 CultureNames.Add ("mn", map);
613 map=new CultureMap("mn-MN", "mn-MN", "MON", 0x0450, 0x0450, 0x0050);
614 CultureID.Add (0x0450, map);
615 CultureNames.Add ("mn-MN", map);*/
617 map=new CultureMap("no", "no", "NOR", 0x0014, 0x0414, 0x007f);
618 CultureID.Add (0x0014, map);
619 CultureNames.Add ("no", map);
621 map=new CultureMap("nb-NO", "nb_NO", "NOR", 0x0414, 0x0414, 0x0014);
622 CultureID.Add (0x0414, map);
623 CultureNames.Add ("nb-NO", map);
625 map=new CultureMap("nn-NO", "nn_NO", "NON", 0x0814, 0x0814, 0x0014);
626 CultureID.Add (0x0814, map);
627 CultureNames.Add ("nn-NO", map);
629 map=new CultureMap("pl", "pl", "PLK", 0x0015, 0x0415, 0x007f);
630 CultureID.Add (0x0015, map);
631 CultureNames.Add ("pl", map);
633 map=new CultureMap("pl-PL", "pl_PL", "PLK", 0x0415, 0x0415, 0x0015);
634 CultureID.Add (0x0415, map);
635 CultureNames.Add ("pl-PL", map);
637 map=new CultureMap("pt", "pt", "PTB", 0x0016, 0x0416, 0x007f);
638 CultureID.Add (0x0016, map);
639 CultureNames.Add ("pt", map);
641 map=new CultureMap("pt-BR", "pt_BR", "PTB", 0x0416, 0x0416, 0x0016);
642 CultureID.Add (0x0416, map);
643 CultureNames.Add ("pt-BR", map);
645 map=new CultureMap("pt-PT", "pt_PT", "PTG", 0x0816, 0x0816, 0x0016);
646 CultureID.Add (0x0816, map);
647 CultureNames.Add ("pt-PT", map);
649 /* Punjabi not supported
650 map=new CultureMap("pa", "pa", "PAN", 0x0046, 0x0446, 0x007f);
651 CultureID.Add (0x0046, map);
652 CultureNames.Add ("pa", map);
654 map=new CultureMap("pa-IN", "pa-IN", "PAN", 0x0446, 0x0446, 0x0046);
655 CultureID.Add (0x0446, map);
656 CultureNames.Add ("pa-IN", map);*/
658 map=new CultureMap("ro", "ro", "ROM", 0x0018, 0x0418, 0x007f);
659 CultureID.Add (0x0018, map);
660 CultureNames.Add ("ro", map);
662 map=new CultureMap("ro-RO", "ro_RO", "ROM", 0x0418, 0x0418, 0x0018);
663 CultureID.Add (0x0418, map);
664 CultureNames.Add ("ro-RO", map);
666 map=new CultureMap("ru", "ru", "RUS", 0x0019, 0x0419, 0x007f);
667 CultureID.Add (0x0019, map);
668 CultureNames.Add ("ru", map);
670 map=new CultureMap("ru-RU", "ru_RU", "RUS", 0x0419, 0x0419, 0x0019);
671 CultureID.Add (0x0419, map);
672 CultureNames.Add ("ru-RU", map);
674 /* Sanskrit not supported
675 map=new CultureMap("sa", "sa", "SAN", 0x004f, 0x044f, 0x007f);
676 CultureID.Add (0x004f, map);
677 CultureNames.Add ("sa", map);
679 map=new CultureMap("sa-IN", "sa-IN", "SAN", 0x044f, 0x044f, 0x004f);
680 CultureID.Add (0x044f, map);
681 CultureNames.Add ("sa-IN", map);*/
683 map=new CultureMap("Cy-sr-SP", "sr", "SRB", 0x0c1a, 0x0c1a, 0x001a);
684 CultureID.Add (0x0c1a, map);
685 CultureNames.Add ("Cy-sr-SP", map);
687 map=new CultureMap("Lt-sr-SP", "sh", "SRL", 0x081a, 0x081a, 0x001a);
688 CultureID.Add (0x081a, map);
689 CultureNames.Add ("Lt-sr-SP", map);
691 map=new CultureMap("sk", "sk", "SKY", 0x001b, 0x041b, 0x007f);
692 CultureID.Add (0x001b, map);
693 CultureNames.Add ("sk", map);
695 map=new CultureMap("sk-SK", "sk_SK", "SKY", 0x041b, 0x041b, 0x001b);
696 CultureID.Add (0x041b, map);
697 CultureNames.Add ("sk-SK", map);
699 map=new CultureMap("sl", "sl", "SLV", 0x0024, 0x0424, 0x007f);
700 CultureID.Add (0x0024, map);
701 CultureNames.Add ("sl", map);
703 map=new CultureMap("sl-SI", "sl_SI", "SLV", 0x0424, 0x0424, 0x0024);
704 CultureID.Add (0x0424, map);
705 CultureNames.Add ("sl-SI", map);
707 map=new CultureMap("es", "es", "ESP", 0x000a, 0x0c0a, 0x007f);
708 CultureID.Add (0x000a, map);
709 CultureNames.Add ("es", map);
711 map=new CultureMap("es-AR", "es_AR", "ESS", 0x2c0a, 0x2c0a, 0x000a);
712 CultureID.Add (0x2c0a, map);
713 CultureNames.Add ("es-AR", map);
715 map=new CultureMap("es-BO", "es_BO", "ESB", 0x400a, 0x400a, 0x000a);
716 CultureID.Add (0x400a, map);
717 CultureNames.Add ("es-BO", map);
719 map=new CultureMap("es-CL", "es_CL", "ESL", 0x340a, 0x340a, 0x000a);
720 CultureID.Add (0x340a, map);
721 CultureNames.Add ("es-CL", map);
723 map=new CultureMap("es-CO", "es_CO", "ESO", 0x240a, 0x240a, 0x000a);
724 CultureID.Add (0x240a, map);
725 CultureNames.Add ("es-CO", map);
727 map=new CultureMap("es-CR", "es_CR", "ESC", 0x140a, 0x140a, 0x000a);
728 CultureID.Add (0x140a, map);
729 CultureNames.Add ("es-CR", map);
731 map=new CultureMap("es-DO", "es_DO", "ESD", 0x1c0a, 0x1c0a, 0x000a);
732 CultureID.Add (0x1c0a, map);
733 CultureNames.Add ("es-DO", map);
735 map=new CultureMap("es-EC", "es_EC", "ESF", 0x300a, 0x300a, 0x000a);
736 CultureID.Add (0x300a, map);
737 CultureNames.Add ("es-EC", map);
739 map=new CultureMap("es-SV", "es_SV", "ESE", 0x440a, 0x440a, 0x000a);
740 CultureID.Add (0x440a, map);
741 CultureNames.Add ("es-SV", map);
743 map=new CultureMap("es-GT", "es_GT", "ESG", 0x100a, 0x100a, 0x000a);
744 CultureID.Add (0x100a, map);
745 CultureNames.Add ("es-GT", map);
747 map=new CultureMap("es-HN", "es_HN", "ESH", 0x480a, 0x480a, 0x000a);
748 CultureID.Add (0x480a, map);
749 CultureNames.Add ("es-HN", map);
751 map=new CultureMap("es-MX", "es_MX", "ESM", 0x080a, 0x080a, 0x000a);
752 CultureID.Add (0x080a, map);
753 CultureNames.Add ("es-MX", map);
755 map=new CultureMap("es-NI", "es_NI", "ESI", 0x4c0a, 0x4c0a, 0x000a);
756 CultureID.Add (0x4c0a, map);
757 CultureNames.Add ("es-NI", map);
759 map=new CultureMap("es-PA", "es_PA", "ESA", 0x180a, 0x180a, 0x000a);
760 CultureID.Add (0x180a, map);
761 CultureNames.Add ("es-PA", map);
763 map=new CultureMap("es-PY", "es_PY", "ESZ", 0x3c0a, 0x3c0a, 0x000a);
764 CultureID.Add (0x3c0a, map);
765 CultureNames.Add ("es-PY", map);
767 map=new CultureMap("es-PE", "es_PE", "ESR", 0x280a, 0x280a, 0x000a);
768 CultureID.Add (0x280a, map);
769 CultureNames.Add ("es-PE", map);
771 map=new CultureMap("es-PR", "es_PR", "ESU", 0x500a, 0x500a, 0x000a);
772 CultureID.Add (0x500a, map);
773 CultureNames.Add ("es-PR", map);
775 map=new CultureMap("es-ES", "es_ES", "ESN", 0x0c0a, 0x0c0a, 0x000a);
776 CultureID.Add (0x0c0a, map);
777 CultureNames.Add ("es-ES", map);
779 map=new CultureMap("es-UY", "es_UY", "ESY", 0x380a, 0x380a, 0x000a);
780 CultureID.Add (0x380a, map);
781 CultureNames.Add ("es-UY", map);
783 map=new CultureMap("es-VE", "es_VE", "ESV", 0x200a, 0x200a, 0x000a);
784 CultureID.Add (0x200a, map);
785 CultureNames.Add ("es-VE", map);
787 map=new CultureMap("sw", "sw", "SWK", 0x0041, 0x0441, 0x007f);
788 CultureID.Add (0x0041, map);
789 CultureNames.Add ("sw", map);
791 map=new CultureMap("sw-KE", "sw_KE", "SWK", 0x0441, 0x0441, 0x0041);
792 CultureID.Add (0x0441, map);
793 CultureNames.Add ("sw-KE", map);
795 map=new CultureMap("sv", "sv", "SVE", 0x001d, 0x041d, 0x007f);
796 CultureID.Add (0x001d, map);
797 CultureNames.Add ("sv", map);
799 map=new CultureMap("sv-FI", "sv_FI", "SVF", 0x081d, 0x081d, 0x001d);
800 CultureID.Add (0x081d, map);
801 CultureNames.Add ("sv-FI", map);
803 map=new CultureMap("sv-SE", "sv_SE", "SVE", 0x041d, 0x041d, 0x001d);
804 CultureID.Add (0x041d, map);
805 CultureNames.Add ("sv-SE", map);
807 /* Syriac not supported
808 map=new CultureMap("syr", "syr", "SYR", 0x005a, 0x045a, 0x007f);
809 CultureID.Add (0x005a, map);
810 CultureNames.Add ("syr", map);
812 map=new CultureMap("syr-SY", "syr-SY", "SYR", 0x045a, 0x045a, 0x005a);
813 CultureID.Add (0x045a, map);
814 CultureNames.Add ("syr-SY", map);*/
816 map=new CultureMap("ta", "ta", "TAM", 0x0049, 0x0449, 0x007f);
817 CultureID.Add (0x0049, map);
818 CultureNames.Add ("ta", map);
820 map=new CultureMap("ta-IN", "ta_IN", "TAM", 0x0449, 0x0449, 0x0049);
821 CultureID.Add (0x0449, map);
822 CultureNames.Add ("ta-IN", map);
824 /* Tatar not supported
825 map=new CultureMap("tt", "tt", "TTT", 0x0044, 0x0444, 0x007f);
826 CultureID.Add (0x0044, map);
827 CultureNames.Add ("tt", map);
829 map=new CultureMap("tt-RU", "tt-RU", "TTT", 0x0444, 0x0444, 0x0044);
830 CultureID.Add (0x0444, map);
831 CultureNames.Add ("tt-RU", map);*/
833 map=new CultureMap("te", "te", "TEL", 0x004a, 0x044a, 0x007f);
834 CultureID.Add (0x004a, map);
835 CultureNames.Add ("te", map);
837 map=new CultureMap("te-IN", "te_IN", "TEL", 0x044a, 0x044a, 0x004a);
838 CultureID.Add (0x044a, map);
839 CultureNames.Add ("te-IN", map);
841 map=new CultureMap("th", "th", "THA", 0x001e, 0x041e, 0x007f);
842 CultureID.Add (0x001e, map);
843 CultureNames.Add ("th", map);
845 /* _TRADITIONAL variant too */
846 map=new CultureMap("th-TH", "th_TH", "THA", 0x041e, 0x041e, 0x001e);
847 CultureID.Add (0x041e, map);
848 CultureNames.Add ("th-TH", map);
850 map=new CultureMap("tr", "tr", "TRK", 0x001f, 0x041f, 0x007f);
851 CultureID.Add (0x001f, map);
852 CultureNames.Add ("tr", map);
854 map=new CultureMap("tr-TR", "tr_TR", "TRK", 0x041f, 0x041f, 0x001f);
855 CultureID.Add (0x041f, map);
856 CultureNames.Add ("tr-TR", map);
858 map=new CultureMap("uk", "uk", "UKR", 0x0022, 0x0422, 0x007f);
859 CultureID.Add (0x0022, map);
860 CultureNames.Add ("uk", map);
862 map=new CultureMap("uk-UA", "uk_UA", "UKR", 0x0422, 0x0422, 0x0022);
863 CultureID.Add (0x0422, map);
864 CultureNames.Add ("uk-UA", map);
866 /* Urdu not supported
867 map=new CultureMap("ur", "ur", "URD", 0x0020, 0x0420, 0x007f);
868 CultureID.Add (0x0020, map);
869 CultureNames.Add ("ur", map);
871 map=new CultureMap("ur-PK", "ur-PK", "URD", 0x0420, 0x0420, 0x0020);
872 CultureID.Add (0x0420, map);
873 CultureNames.Add ("ur-PK", map);*/
875 /* Uzbek not supported
876 map=new CultureMap("uz", "uz", "UZB", 0x0043, 0x0443, 0x007f);
877 CultureID.Add (0x0043, map);
878 CultureNames.Add ("uz", map);
880 map=new CultureMap("Cy-uz-UZ", "Cy-uz-UZ", "UZB", 0x0843, 0x0843, 0x0043);
881 CultureID.Add (0x0843, map);
882 CultureNames.Add ("Cy-uz-UZ", map);
884 map=new CultureMap("Lt-uz-UZ", "Lt-uz-UZ", "UZB", 0x0443, 0x0443, 0x0043);
885 CultureID.Add (0x0443, map);
886 CultureNames.Add ("Lt-uz-UZ", map);*/
888 map=new CultureMap("vi", "vi", "VIT", 0x002a, 0x042a, 0x007f);
889 CultureID.Add (0x002a, map);
890 CultureNames.Add ("vi", map);
892 map=new CultureMap("vi-VN", "vi_VN", "VIT", 0x042a, 0x042a, 0x002a);
893 CultureID.Add (0x042a, map);
894 CultureNames.Add ("vi-VN", map);
896 /* Extras not listed in the docs... */
897 map=new CultureMap ("de-DE-PHONEBOOK", "de__PHONEBOOK", "DEU", 0x10407, 0x0407, 0x0007);
898 CultureID.Add (0x10407, map);
899 CultureNames.Add ("de-DE-PHONEBOOK",map);
901 map=new CultureMap ("es-ES-Ts", "es__TRADITIONAL", "ESN", 0x040a, 0x0c0a, 0x000a);
902 CultureID.Add (0x040a, map);
903 CultureNames.Add ("es-ES-Ts", map);
905 /* Others not supported by ms */
907 map=new CultureMap ("bn", "dn", "", 0x0045, 0x0445, 0x007f);
908 CultureID.Add (0x0045, map);
909 CultureNames.Add ("bn", map);
911 map=new CultureMap ("bn-IN", "bn_IN", "", 0x0445, 0x0445, 0x0045);
912 CultureID.Add (0x0445,map);
913 CultureNames.Add ("bn-IN", map);
915 map=new CultureMap ("mt", "mt", "", 0x003a, 0x043a, 0x007f);
916 CultureID.Add (0x003a, map);
917 CultureNames.Add ("mt", map);
919 map=new CultureMap ("mt-MT", "mt_MT", "", 0x043a, 0x043a, 0x003a);
920 CultureID.Add (0x043a, map);
921 CultureNames.Add ("mt-MT", map);
923 map=new CultureMap ("zh-TW-STROKE", "zh_TW_STROKE", "", 0x20404, 0x20404, 0x7c04);
924 CultureID.Add (0x20404, map);
925 CultureNames.Add ("zh-TW-STROKE", map);
927 /* Just need an instance to call
933 public CultureMap (string name, string icu_name,
934 string win3lang, int lcid,
935 int specific_lcid, int parent_lcid)
938 this.icu_name=icu_name;
939 this.win3lang=win3lang;
941 this.specific_lcid=specific_lcid;
942 this.parent_lcid=parent_lcid;
945 public IEnumerator GetEnumerator ()
947 return(new CultureEnumerator (CultureID));
950 public static int name_to_lcid (string name)
952 CultureMap map=CultureNames[name] as CultureMap;
955 throw new ArgumentException ("Culture name "+name+" is not supported.");
961 public static int name_to_specific_lcid (string name)
963 CultureMap map=CultureNames[name] as CultureMap;
966 throw new ArgumentException ("Culture name "+name+" is not supported.");
969 return(map.specific_lcid);
972 public static string lcid_to_name (int lcid)
974 CultureMap map=CultureID[lcid] as CultureMap;
977 throw new ArgumentException ("Culture ID "+lcid+" (0x"+lcid.ToString ("x4")+") is not supported.");
983 public static string lcid_to_icuname (int lcid)
985 CultureMap map=CultureID[lcid] as CultureMap;
988 throw new ArgumentException ("Culture ID "+lcid+" (0x"+lcid.ToString ("x4")+") is not supported.");
991 return(map.icu_name);
994 public static string lcid_to_win3lang (int lcid)
996 CultureMap map=CultureID[lcid] as CultureMap;
999 throw new ArgumentException ("Culture ID "+lcid+" (0x"+lcid.ToString ("x4")+") is not supported.");
1002 return(map.win3lang);
1005 public static int lcid_to_specific_lcid (int lcid)
1007 CultureMap map=CultureID[lcid] as CultureMap;
1010 throw new ArgumentException ("Culture ID "+lcid+" (0x"+lcid.ToString ("x4")+") is not supported.");
1013 return(map.specific_lcid);
1016 public static int lcid_to_parent_lcid (int lcid)
1018 CultureMap map=CultureID[lcid] as CultureMap;
1021 throw new ArgumentException ("Culture ID "+lcid+" (0x"+lcid.ToString ("x4")+") is not supported.");
1024 return(map.parent_lcid);
1027 private sealed class CultureEnumerator : IEnumerator
1029 IEnumerator hash_enum;
1031 public CultureEnumerator (Hashtable hash)
1033 hash_enum=hash.GetEnumerator ();
1039 DictionaryEntry ent=(DictionaryEntry)hash_enum.Current;
1040 CultureMap map=ent.Value as CultureMap;
1045 object IEnumerator.Current
1052 public bool MoveNext ()
1054 return(hash_enum.MoveNext ());
1057 public void Reset ()
1064 static public CultureInfo InvariantCulture {
1066 if (invariant_culture_info == null) {
1067 lock (typeof (CultureInfo)) {
1068 if (invariant_culture_info == null) {
1069 invariant_culture_info = new CultureInfo (0x7f, false);
1070 invariant_culture_info.is_read_only = true;
1075 return(invariant_culture_info);
1079 public static CultureInfo CreateSpecificCulture (string name)
1082 throw new ArgumentNullException ("name");
1085 CultureInfo culture=new CultureInfo (name);
1086 if(culture.IsNeutralCulture==false) {
1090 return(new CultureInfo (CultureMap.name_to_specific_lcid (name)));
1093 public static CultureInfo CurrentCulture
1096 return Thread.CurrentThread.CurrentCulture;
1100 public static CultureInfo CurrentUICulture
1103 return Thread.CurrentThread.CurrentUICulture;
1108 public virtual int LCID {
1114 public virtual string Name {
1120 public virtual string NativeName
1129 public virtual Calendar Calendar
1131 get { return null; }
1135 public virtual Calendar[] OptionalCalendars
1142 public virtual CultureInfo Parent
1145 return(new CultureInfo (CultureMap.lcid_to_parent_lcid (lcid)));
1149 public virtual TextInfo TextInfo
1152 if (textinfo == null) {
1154 if(textinfo == null) {
1155 textinfo = new TextInfo (lcid);
1164 public virtual string ThreeLetterISOLanguageName
1171 public virtual string ThreeLetterWindowsLanguageName
1178 public virtual string TwoLetterISOLanguageName
1185 public bool UseUserOverride
1188 return use_user_override;
1193 public void ClearCachedData()
1197 public virtual object Clone()
1199 CultureInfo ci=(CultureInfo)MemberwiseClone ();
1200 ci.is_read_only=false;
1204 public override bool Equals (object value)
1206 CultureInfo b = value as CultureInfo;
1208 return b.lcid == lcid;
1212 public static CultureInfo[] GetCultures(CultureTypes types)
1214 bool neutral=((types & CultureTypes.NeutralCultures)!=0);
1215 bool specific=((types & CultureTypes.SpecificCultures)!=0);
1216 bool installed=((types & CultureTypes.InstalledWin32Cultures)!=0); // TODO
1218 ArrayList arr=new ArrayList ();
1220 foreach (int id in CultureMap.lcids) {
1221 bool is_neutral=IsIDNeutralCulture (id);
1223 if((neutral && is_neutral) ||
1224 (specific && !is_neutral)) {
1225 arr.Add (new CultureInfo (id));
1229 CultureInfo[] cultures=new CultureInfo[arr.Count];
1230 arr.CopyTo (cultures, 0);
1235 public override int GetHashCode()
1240 public static CultureInfo ReadOnly(CultureInfo ci)
1243 throw new ArgumentNullException("ci");
1246 if(ci.is_read_only) {
1249 CultureInfo new_ci=(CultureInfo)ci.Clone ();
1250 new_ci.is_read_only=true;
1255 public override string ToString()
1260 public virtual CompareInfo CompareInfo
1263 if(compareinfo==null) {
1265 if(compareinfo==null) {
1266 compareinfo=new CompareInfo (lcid);
1271 return(compareinfo);
1275 /* RegionInfo wants to call this method */
1276 internal static bool IsIDNeutralCulture (int lcid)
1278 return((lcid & 0xff00)==0 ||
1279 /* Chinese zh-CHS and zh-CHT are
1280 * treated as neutral too
1282 CultureMap.lcid_to_specific_lcid (lcid)==0);
1285 public virtual bool IsNeutralCulture {
1287 return(IsIDNeutralCulture (lcid));
1291 public virtual NumberFormatInfo NumberFormat {
1293 if (number_format == null){
1295 if (number_format == null)
1296 number_format = new NumberFormatInfo (lcid);
1300 return number_format;
1304 if (is_read_only) throw new InvalidOperationException(MSG_READONLY);
1307 throw new ArgumentNullException ("NumberFormat");
1309 number_format = value;
1313 public virtual DateTimeFormatInfo DateTimeFormat
1317 if (datetime_format == null)
1321 if (datetime_format == null)
1322 datetime_format = new DateTimeFormatInfo();
1326 return datetime_format;
1331 if (is_read_only) throw new InvalidOperationException(MSG_READONLY);
1334 throw new ArgumentNullException ("DateTimeFormat");
1336 datetime_format = value;
1340 public virtual string DisplayName
1343 return(displayname);
1347 public virtual string EnglishName
1350 return(englishname);
1355 public static CultureInfo InstalledUICulture
1362 public bool IsReadOnly
1365 return(is_read_only);
1371 // IFormatProvider implementation
1373 public virtual object GetFormat( Type formatType )
1375 object format = null;
1377 if ( formatType == typeof(NumberFormatInfo) )
1378 format = NumberFormat;
1379 else if ( formatType == typeof(DateTimeFormatInfo) )
1380 format = DateTimeFormat;
1388 [MethodImplAttribute (MethodImplOptions.InternalCall)]
1389 private extern void construct_internal_locale (string locale);
1391 private void Construct (int lcid, string name,
1392 bool use_user_override)
1394 /* This will throw ArgumentException if the
1395 * locale isnt known.
1397 * Asking CultureMap for the name gets the
1398 * capitalisation correct, as in practise
1399 * (rather than by documentation) the name is
1402 this.name=CultureMap.lcid_to_name (lcid);
1403 this.icu_name=CultureMap.lcid_to_icuname (lcid);
1404 this.use_user_override=use_user_override;
1405 this.is_read_only=false;
1408 /* This will throw ArgumentException if
1409 * CultureMap doesn't know the culture
1411 this.win3lang=CultureMap.lcid_to_win3lang (lcid);
1413 /* This will throw ArgumentException if ICU
1414 * doesn't know the culture
1416 construct_internal_locale (CultureMap.lcid_to_icuname (lcid));
1419 /* Do _NOT_ use CultureMap in this method, we don't
1420 * want to initialise the hashtables unless someone
1421 * asks for a real CultureInfo.
1423 private void ConstructInvariant (bool use_user_override)
1427 this.use_user_override=use_user_override;
1429 /* NumberFormatInfo defaults to the invariant data */
1430 number_format=new NumberFormatInfo ();
1432 /* DateTimeFormatInfo defaults to the invariant data */
1433 datetime_format=new DateTimeFormatInfo ();
1435 textinfo=new TextInfo ();
1438 displayname="Invariant Language (Invariant Country)";
1439 englishname="Invariant Language (Invariant Country)";
1440 nativename="Invariant Language (Invariant Country)";
1443 icu_name="en_US_POSIX";
1447 public CultureInfo (int culture, bool use_user_override)
1450 throw new ArgumentOutOfRangeException ("culture");
1452 if(culture==0x007f) {
1453 /* Short circuit the invariant culture */
1454 ConstructInvariant (use_user_override);
1457 CultureMap.lcid_to_name (culture),
1462 public CultureInfo (int culture) : this (culture, false) {}
1464 public CultureInfo (string name, bool use_user_override)
1467 throw new ArgumentNullException ();
1470 /* Short circuit the invariant culture */
1471 ConstructInvariant (use_user_override);
1473 Construct (CultureMap.name_to_lcid (name),
1479 public CultureInfo (string name) : this (name, false) {}