1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System.Collections.Generic;
6 using System.Diagnostics;
8 using System.Threading;
10 namespace System.Globalization
13 using StringStringDictionary = Dictionary<string, string>;
14 using StringCultureDataDictionary = Dictionary<string, CultureData>;
15 using LcidToCultureNameDictionary = Dictionary<int, string>;
18 using StringStringDictionary = LowLevelDictionary<string, string>;
19 using StringCultureDataDictionary = LowLevelDictionary<string, CultureData>;
20 using LcidToCultureNameDictionary = LowLevelDictionary<int, string>;
24 // List of culture data
25 // Note the we cache overrides.
26 // Note that localized names (resource names) aren't available from here.
30 // Our names are a tad confusing.
32 // sWindowsName -- The name that windows thinks this culture is, ie:
33 // en-US if you pass in en-US
34 // de-DE_phoneb if you pass in de-DE_phoneb
35 // fj-FJ if you pass in fj (neutral, on a pre-Windows 7 machine)
36 // fj if you pass in fj (neutral, post-Windows 7 machine)
38 // sRealName -- The name you used to construct the culture, in pretty form
39 // en-US if you pass in EN-us
40 // en if you pass in en
41 // de-DE_phoneb if you pass in de-DE_phoneb
43 // sSpecificCulture -- The specific culture for this culture
46 // de-DE_phoneb for alt sort
47 // fj-FJ for fj (neutral)
49 // sName -- The IETF name of this culture (ie: no sort info, could be neutral)
50 // en-US if you pass in en-US
51 // en if you pass in en
52 // de-DE if you pass in de-DE_phoneb
54 internal partial class CultureData
56 private const int LOCALE_NAME_MAX_LENGTH = 85;
57 private const int undef = -1;
60 private String _sRealName; // Name you passed in (ie: en-US, en, or de-DE_phoneb)
61 private String _sWindowsName; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in))
64 private String _sName; // locale name (ie: en-us, NO sort info, but could be neutral)
65 private String _sParent; // Parent name (which may be a custom locale/culture)
66 private String _sLocalizedDisplayName; // Localized pretty name for this locale
67 private String _sEnglishDisplayName; // English pretty name for this locale
68 private String _sNativeDisplayName; // Native pretty name for this locale
69 private String _sSpecificCulture; // The culture name to be used in CultureInfo.CreateSpecificCulture(), en-US form if neutral, sort name if sort
72 private String _sISO639Language; // ISO 639 Language Name
73 private String _sISO639Language2; // ISO 639 Language Name
74 private String _sLocalizedLanguage; // Localized name for this language
75 private String _sEnglishLanguage; // English name for this language
76 private String _sNativeLanguage; // Native name of this language
77 private String _sAbbrevLang; // abbreviated language name (Windows Language Name) ex: ENU
78 private string _sConsoleFallbackName; // The culture name for the console fallback UI culture
79 private int _iInputLanguageHandle=undef;// input language handle
82 private String _sRegionName; // (RegionInfo)
83 private String _sLocalizedCountry; // localized country name
84 private String _sEnglishCountry; // english country name (RegionInfo)
85 private String _sNativeCountry; // native country name
86 private String _sISO3166CountryName; // ISO 3166 (RegionInfo), ie: US
87 private String _sISO3166CountryName2; // 3 char ISO 3166 country name 2 2(RegionInfo) ex: USA (ISO)
88 private int _iGeoId = undef; // GeoId
91 private String _sPositiveSign; // (user can override) positive sign
92 private String _sNegativeSign; // (user can override) negative sign
93 // (nfi populates these 5, don't have to be = undef)
94 private int _iDigits; // (user can override) number of fractional digits
95 private int _iNegativeNumber; // (user can override) negative number format
96 private int[] _waGrouping; // (user can override) grouping of digits
97 private String _sDecimalSeparator; // (user can override) decimal separator
98 private String _sThousandSeparator; // (user can override) thousands separator
99 private String _sNaN; // Not a Number
100 private String _sPositiveInfinity; // + Infinity
101 private String _sNegativeInfinity; // - Infinity
104 private int _iNegativePercent = undef; // Negative Percent (0-3)
105 private int _iPositivePercent = undef; // Positive Percent (0-11)
106 private String _sPercent; // Percent (%) symbol
107 private String _sPerMille; // PerMille symbol
110 private String _sCurrency; // (user can override) local monetary symbol
111 private String _sIntlMonetarySymbol; // international monetary symbol (RegionInfo)
112 private String _sEnglishCurrency; // English name for this currency
113 private String _sNativeCurrency; // Native name for this currency
114 // (nfi populates these 4, don't have to be = undef)
115 private int _iCurrencyDigits; // (user can override) # local monetary fractional digits
116 private int _iCurrency; // (user can override) positive currency format
117 private int _iNegativeCurrency; // (user can override) negative currency format
118 private int[] _waMonetaryGrouping; // (user can override) monetary grouping of digits
119 private String _sMonetaryDecimal; // (user can override) monetary decimal separator
120 private String _sMonetaryThousand; // (user can override) monetary thousands separator
123 private int _iMeasure = undef; // (user can override) system of measurement 0=metric, 1=US (RegionInfo)
124 private String _sListSeparator; // (user can override) list separator
127 private String _sAM1159; // (user can override) AM designator
128 private String _sPM2359; // (user can override) PM designator
129 private String _sTimeSeparator;
130 private volatile String[] _saLongTimes; // (user can override) time format
131 private volatile String[] _saShortTimes; // short time format
132 private volatile String[] _saDurationFormats; // time duration format
134 // Calendar specific data
135 private int _iFirstDayOfWeek = undef; // (user can override) first day of week (gregorian really)
136 private int _iFirstWeekOfYear = undef; // (user can override) first week of year (gregorian really)
137 private volatile CalendarId[] _waCalendars; // all available calendar type(s). The first one is the default calendar
139 // Store for specific data about each calendar
140 private CalendarData[] _calendars; // Store for specific calendar data
143 private int _iReadingLayout = undef; // Reading layout data
144 // 0 - Left to right (eg en-US)
145 // 1 - Right to left (eg arabic locales)
146 // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
147 // 3 - Vertical top to bottom with columns proceeding to the right
149 // CoreCLR depends on this even though its not exposed publicly.
151 private int _iDefaultAnsiCodePage = undef; // default ansi code page ID (ACP)
152 private int _iDefaultOemCodePage = undef; // default oem code page ID (OCP or OEM)
153 private int _iDefaultMacCodePage = undef; // default macintosh code page
154 private int _iDefaultEbcdicCodePage = undef; // default EBCDIC code page
156 private int _iLanguage; // locale ID (0409) - NO sort information
157 private bool _bUseOverrides; // use user overrides?
158 private bool _bNeutral; // Flags for the culture (ie: neutral or not right now)
160 // Region Name to Culture Name mapping table
161 // (In future would be nice to be in registry or something)
163 //Using a property so we avoid creating the dictionary until we need it
164 private static StringStringDictionary RegionNames
168 if (s_RegionNames == null)
170 StringStringDictionary regionNames = new StringStringDictionary(211 /* prime */);
172 regionNames.Add("029", "en-029");
173 regionNames.Add("AE", "ar-AE");
174 regionNames.Add("AF", "prs-AF");
175 regionNames.Add("AL", "sq-AL");
176 regionNames.Add("AM", "hy-AM");
177 regionNames.Add("AR", "es-AR");
178 regionNames.Add("AT", "de-AT");
179 regionNames.Add("AU", "en-AU");
180 regionNames.Add("AZ", "az-Cyrl-AZ");
181 regionNames.Add("BA", "bs-Latn-BA");
182 regionNames.Add("BD", "bn-BD");
183 regionNames.Add("BE", "nl-BE");
184 regionNames.Add("BG", "bg-BG");
185 regionNames.Add("BH", "ar-BH");
186 regionNames.Add("BN", "ms-BN");
187 regionNames.Add("BO", "es-BO");
188 regionNames.Add("BR", "pt-BR");
189 regionNames.Add("BY", "be-BY");
190 regionNames.Add("BZ", "en-BZ");
191 regionNames.Add("CA", "en-CA");
192 regionNames.Add("CH", "it-CH");
193 regionNames.Add("CL", "es-CL");
194 regionNames.Add("CN", "zh-CN");
195 regionNames.Add("CO", "es-CO");
196 regionNames.Add("CR", "es-CR");
197 regionNames.Add("CS", "sr-Cyrl-CS");
198 regionNames.Add("CZ", "cs-CZ");
199 regionNames.Add("DE", "de-DE");
200 regionNames.Add("DK", "da-DK");
201 regionNames.Add("DO", "es-DO");
202 regionNames.Add("DZ", "ar-DZ");
203 regionNames.Add("EC", "es-EC");
204 regionNames.Add("EE", "et-EE");
205 regionNames.Add("EG", "ar-EG");
206 regionNames.Add("ES", "es-ES");
207 regionNames.Add("ET", "am-ET");
208 regionNames.Add("FI", "fi-FI");
209 regionNames.Add("FO", "fo-FO");
210 regionNames.Add("FR", "fr-FR");
211 regionNames.Add("GB", "en-GB");
212 regionNames.Add("GE", "ka-GE");
213 regionNames.Add("GL", "kl-GL");
214 regionNames.Add("GR", "el-GR");
215 regionNames.Add("GT", "es-GT");
216 regionNames.Add("HK", "zh-HK");
217 regionNames.Add("HN", "es-HN");
218 regionNames.Add("HR", "hr-HR");
219 regionNames.Add("HU", "hu-HU");
220 regionNames.Add("ID", "id-ID");
221 regionNames.Add("IE", "en-IE");
222 regionNames.Add("IL", "he-IL");
223 regionNames.Add("IN", "hi-IN");
224 regionNames.Add("IQ", "ar-IQ");
225 regionNames.Add("IR", "fa-IR");
226 regionNames.Add("IS", "is-IS");
227 regionNames.Add("IT", "it-IT");
228 regionNames.Add("IV", "");
229 regionNames.Add("JM", "en-JM");
230 regionNames.Add("JO", "ar-JO");
231 regionNames.Add("JP", "ja-JP");
232 regionNames.Add("KE", "sw-KE");
233 regionNames.Add("KG", "ky-KG");
234 regionNames.Add("KH", "km-KH");
235 regionNames.Add("KR", "ko-KR");
236 regionNames.Add("KW", "ar-KW");
237 regionNames.Add("KZ", "kk-KZ");
238 regionNames.Add("LA", "lo-LA");
239 regionNames.Add("LB", "ar-LB");
240 regionNames.Add("LI", "de-LI");
241 regionNames.Add("LK", "si-LK");
242 regionNames.Add("LT", "lt-LT");
243 regionNames.Add("LU", "lb-LU");
244 regionNames.Add("LV", "lv-LV");
245 regionNames.Add("LY", "ar-LY");
246 regionNames.Add("MA", "ar-MA");
247 regionNames.Add("MC", "fr-MC");
248 regionNames.Add("ME", "sr-Latn-ME");
249 regionNames.Add("MK", "mk-MK");
250 regionNames.Add("MN", "mn-MN");
251 regionNames.Add("MO", "zh-MO");
252 regionNames.Add("MT", "mt-MT");
253 regionNames.Add("MV", "dv-MV");
254 regionNames.Add("MX", "es-MX");
255 regionNames.Add("MY", "ms-MY");
256 regionNames.Add("NG", "ig-NG");
257 regionNames.Add("NI", "es-NI");
258 regionNames.Add("NL", "nl-NL");
259 regionNames.Add("NO", "nn-NO");
260 regionNames.Add("NP", "ne-NP");
261 regionNames.Add("NZ", "en-NZ");
262 regionNames.Add("OM", "ar-OM");
263 regionNames.Add("PA", "es-PA");
264 regionNames.Add("PE", "es-PE");
265 regionNames.Add("PH", "en-PH");
266 regionNames.Add("PK", "ur-PK");
267 regionNames.Add("PL", "pl-PL");
268 regionNames.Add("PR", "es-PR");
269 regionNames.Add("PT", "pt-PT");
270 regionNames.Add("PY", "es-PY");
271 regionNames.Add("QA", "ar-QA");
272 regionNames.Add("RO", "ro-RO");
273 regionNames.Add("RS", "sr-Latn-RS");
274 regionNames.Add("RU", "ru-RU");
275 regionNames.Add("RW", "rw-RW");
276 regionNames.Add("SA", "ar-SA");
277 regionNames.Add("SE", "sv-SE");
278 regionNames.Add("SG", "zh-SG");
279 regionNames.Add("SI", "sl-SI");
280 regionNames.Add("SK", "sk-SK");
281 regionNames.Add("SN", "wo-SN");
282 regionNames.Add("SV", "es-SV");
283 regionNames.Add("SY", "ar-SY");
284 regionNames.Add("TH", "th-TH");
285 regionNames.Add("TJ", "tg-Cyrl-TJ");
286 regionNames.Add("TM", "tk-TM");
287 regionNames.Add("TN", "ar-TN");
288 regionNames.Add("TR", "tr-TR");
289 regionNames.Add("TT", "en-TT");
290 regionNames.Add("TW", "zh-TW");
291 regionNames.Add("UA", "uk-UA");
292 regionNames.Add("US", "en-US");
293 regionNames.Add("UY", "es-UY");
294 regionNames.Add("UZ", "uz-Cyrl-UZ");
295 regionNames.Add("VE", "es-VE");
296 regionNames.Add("VN", "vi-VN");
297 regionNames.Add("YE", "ar-YE");
298 regionNames.Add("ZA", "af-ZA");
299 regionNames.Add("ZW", "en-ZW");
301 s_RegionNames = regionNames;
304 return s_RegionNames;
308 // Cache of regions we've already looked up
309 private static volatile StringCultureDataDictionary s_cachedRegions;
310 private static volatile StringStringDictionary s_RegionNames;
312 internal static CultureData GetCultureDataForRegion(String cultureName, bool useUserOverride)
314 // First do a shortcut for Invariant
315 if (String.IsNullOrEmpty(cultureName))
317 return CultureData.Invariant;
321 // First check if GetCultureData() can find it (ie: its a real culture)
323 CultureData retVal = GetCultureData(cultureName, useUserOverride);
324 if (retVal != null && (retVal.IsNeutralCulture == false)) return retVal;
327 // Not a specific culture, perhaps it's region-only name
328 // (Remember this isn't a core clr path where that's not supported)
331 // If it was neutral remember that so that RegionInfo() can throw the right exception
332 CultureData neutral = retVal;
334 // Try the hash table next
335 String hashName = AnsiToLower(useUserOverride ? cultureName : cultureName + '*');
336 StringCultureDataDictionary tempHashTable = s_cachedRegions;
337 if (tempHashTable == null)
339 // No table yet, make a new one
340 tempHashTable = new StringCultureDataDictionary();
344 // Check the hash table
347 tempHashTable.TryGetValue(hashName, out retVal);
356 // Not found in the hash table, look it up the hard way
359 // If not a valid mapping from the registry we'll have to try the hard coded table
360 if (retVal == null || (retVal.IsNeutralCulture == true))
362 // Not a valid mapping, try the hard coded table
364 if (RegionNames.TryGetValue(cultureName, out name))
366 // Make sure we can get culture data for it
367 retVal = GetCultureData(name, useUserOverride);
371 // If not found in the hard coded table we'll have to find a culture that works for us
372 if (retVal == null || (retVal.IsNeutralCulture == true))
374 retVal = GetCultureDataFromRegionName(cultureName);
377 // If we found one we can use, then cache it for next time
378 if (retVal != null && (retVal.IsNeutralCulture == false))
380 // first add it to the cache
383 tempHashTable[hashName] = retVal;
386 // Copy the hashtable to the corresponding member variables. This will potentially overwrite
387 // new tables simultaneously created by a new thread, but maximizes thread safety.
388 s_cachedRegions = tempHashTable;
392 // Unable to find a matching culture/region, return null or neutral
393 // (regionInfo throws a more specific exception on neutrals)
397 // Return the found culture to use, null, or the neutral culture.
401 // Clear our internal caches
402 internal static void ClearCachedData()
404 s_cachedCultures = null;
405 s_cachedRegions = null;
408 internal static CultureInfo[] GetCultures(CultureTypes types)
410 // Disable warning 618: System.Globalization.CultureTypes.FrameworkCultures' is obsolete
411 #pragma warning disable 618
413 if ((int)types <= 0 || ((int)types & (int)~(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures |
414 CultureTypes.InstalledWin32Cultures | CultureTypes.UserCustomCulture |
415 CultureTypes.ReplacementCultures | CultureTypes.WindowsOnlyCultures |
416 CultureTypes.FrameworkCultures)) != 0)
418 throw new ArgumentOutOfRangeException(nameof(types),
419 SR.Format(SR.ArgumentOutOfRange_Range, CultureTypes.NeutralCultures, CultureTypes.FrameworkCultures));
422 // We have deprecated CultureTypes.FrameworkCultures.
423 // When this enum is used, we will enumerate Whidbey framework cultures (for compatibility).
425 // We have deprecated CultureTypes.WindowsOnlyCultures.
426 // When this enum is used, we will return an empty array for this enum.
427 if ((types & CultureTypes.WindowsOnlyCultures) != 0)
429 // Remove the enum as it is an no-op.
430 types &= (~CultureTypes.WindowsOnlyCultures);
433 if (GlobalizationMode.Invariant)
435 // in invariant mode we always return invariant culture only from the enumeration
436 return new CultureInfo[1] { new CultureInfo("") };
439 #pragma warning restore 618
440 return EnumCultures(types);
443 private static CultureData CreateCultureWithInvariantData()
445 // Make a new culturedata
446 CultureData invariant = new CultureData();
449 // Note that we override the resources since this IS NOT supposed to change (by definition)
450 invariant._bUseOverrides = false;
451 invariant._sRealName = ""; // Name you passed in (ie: en-US, en, or de-DE_phoneb)
452 invariant._sWindowsName = ""; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passed in))
455 invariant._sName = ""; // locale name (ie: en-us)
456 invariant._sParent = ""; // Parent name (which may be a custom locale/culture)
457 invariant._bNeutral = false; // Flags for the culture (ie: neutral or not right now)
458 invariant._sEnglishDisplayName = "Invariant Language (Invariant Country)"; // English pretty name for this locale
459 invariant._sNativeDisplayName = "Invariant Language (Invariant Country)"; // Native pretty name for this locale
460 invariant._sSpecificCulture = ""; // The culture name to be used in CultureInfo.CreateSpecificCulture()
463 invariant._sISO639Language = "iv"; // ISO 639 Language Name
464 invariant._sISO639Language2 = "ivl"; // 3 char ISO 639 lang name 2
465 invariant._sLocalizedLanguage = "Invariant Language"; // Display name for this Language
466 invariant._sEnglishLanguage = "Invariant Language"; // English name for this language
467 invariant._sNativeLanguage = "Invariant Language"; // Native name of this language
468 invariant._sAbbrevLang = "IVL"; // abbreviated language name (Windows Language Name)
469 invariant._sConsoleFallbackName = ""; // The culture name for the console fallback UI culture
470 invariant._iInputLanguageHandle = 0x07F; // input language handle
473 invariant._sRegionName = "IV"; // (RegionInfo)
474 invariant._sEnglishCountry = "Invariant Country"; // english country name (RegionInfo)
475 invariant._sNativeCountry = "Invariant Country"; // native country name (Windows Only)
476 invariant._sISO3166CountryName = "IV"; // (RegionInfo), ie: US
477 invariant._sISO3166CountryName2 = "ivc"; // 3 char ISO 3166 country name 2 2(RegionInfo)
478 invariant._iGeoId = 244; // GeoId (Windows Only)
481 invariant._sPositiveSign = "+"; // positive sign
482 invariant._sNegativeSign = "-"; // negative sign
483 invariant._iDigits = 2; // number of fractional digits
484 invariant._iNegativeNumber = 1; // negative number format
485 invariant._waGrouping = new int[] { 3 }; // grouping of digits
486 invariant._sDecimalSeparator = "."; // decimal separator
487 invariant._sThousandSeparator = ","; // thousands separator
488 invariant._sNaN = "NaN"; // Not a Number
489 invariant._sPositiveInfinity = "Infinity"; // + Infinity
490 invariant._sNegativeInfinity = "-Infinity"; // - Infinity
493 invariant._iNegativePercent = 0; // Negative Percent (0-3)
494 invariant._iPositivePercent = 0; // Positive Percent (0-11)
495 invariant._sPercent = "%"; // Percent (%) symbol
496 invariant._sPerMille = "\x2030"; // PerMille symbol
499 invariant._sCurrency = "\x00a4"; // local monetary symbol: for international monetary symbol
500 invariant._sIntlMonetarySymbol = "XDR"; // international monetary symbol (RegionInfo)
501 invariant._sEnglishCurrency = "International Monetary Fund"; // English name for this currency (Windows Only)
502 invariant._sNativeCurrency = "International Monetary Fund"; // Native name for this currency (Windows Only)
503 invariant._iCurrencyDigits = 2; // # local monetary fractional digits
504 invariant._iCurrency = 0; // positive currency format
505 invariant._iNegativeCurrency = 0; // negative currency format
506 invariant._waMonetaryGrouping = new int[] { 3 }; // monetary grouping of digits
507 invariant._sMonetaryDecimal = "."; // monetary decimal separator
508 invariant._sMonetaryThousand = ","; // monetary thousands separator
511 invariant._iMeasure = 0; // system of measurement 0=metric, 1=US (RegionInfo)
512 invariant._sListSeparator = ","; // list separator
515 invariant._sTimeSeparator = ":";
516 invariant._sAM1159 = "AM"; // AM designator
517 invariant._sPM2359 = "PM"; // PM designator
518 invariant._saLongTimes = new String[] { "HH:mm:ss" }; // time format
519 invariant._saShortTimes = new String[] { "HH:mm", "hh:mm tt", "H:mm", "h:mm tt" }; // short time format
520 invariant._saDurationFormats = new String[] { "HH:mm:ss" }; // time duration format
523 // Calendar specific data
524 invariant._iFirstDayOfWeek = 0; // first day of week
525 invariant._iFirstWeekOfYear = 0; // first week of year
526 invariant._waCalendars = new CalendarId[] { CalendarId.GREGORIAN }; // all available calendar type(s). The first one is the default calendar
528 // Store for specific data about each calendar
529 invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS];
530 invariant._calendars[0] = CalendarData.Invariant;
533 invariant._iReadingLayout = 0;
535 // These are desktop only, not coreclr
537 invariant._iLanguage = CultureInfo.LOCALE_INVARIANT; // locale ID (0409) - NO sort information
538 invariant._iDefaultAnsiCodePage = 1252; // default ansi code page ID (ACP)
539 invariant._iDefaultOemCodePage = 437; // default oem code page ID (OCP or OEM)
540 invariant._iDefaultMacCodePage = 10000; // default macintosh code page
541 invariant._iDefaultEbcdicCodePage = 037; // default EBCDIC code page
543 if (GlobalizationMode.Invariant)
545 invariant._sLocalizedDisplayName = invariant._sNativeDisplayName;
546 invariant._sLocalizedCountry = invariant._sNativeCountry;
552 /////////////////////////////////////////////////////////////////////////
553 // Build our invariant information
555 // We need an invariant instance, which we build hard-coded
556 /////////////////////////////////////////////////////////////////////////
557 internal static CultureData Invariant
561 if (s_Invariant == null)
564 s_Invariant = CreateCultureWithInvariantData();
569 private volatile static CultureData s_Invariant;
574 // Cache of cultures we've already looked up
575 private static volatile StringCultureDataDictionary s_cachedCultures;
576 private static readonly Lock s_lock = new Lock();
578 internal static CultureData GetCultureData(String cultureName, bool useUserOverride)
580 // First do a shortcut for Invariant
581 if (String.IsNullOrEmpty(cultureName))
583 return CultureData.Invariant;
586 // Try the hash table first
587 String hashName = AnsiToLower(useUserOverride ? cultureName : cultureName + '*');
588 StringCultureDataDictionary tempHashTable = s_cachedCultures;
589 if (tempHashTable == null)
591 // No table yet, make a new one
592 tempHashTable = new StringCultureDataDictionary();
596 // Check the hash table
601 ret = tempHashTable.TryGetValue(hashName, out retVal);
603 if (ret && retVal != null)
609 // Not found in the hash table, need to see if we can build one that works for us
610 CultureData culture = CreateCultureData(cultureName, useUserOverride);
616 // Found one, add it to the cache
619 tempHashTable[hashName] = culture;
622 // Copy the hashtable to the corresponding member variables. This will potentially overwrite
623 // new tables simultaneously created by a new thread, but maximizes thread safety.
624 s_cachedCultures = tempHashTable;
629 private static unsafe string NormalizeCultureName(string name, out bool isNeutralName)
631 isNeutralName = true;
634 Debug.Assert(name.Length <= LOCALE_NAME_MAX_LENGTH);
636 char *pName = stackalloc char[LOCALE_NAME_MAX_LENGTH];
637 bool changed = false;
639 while (i < name.Length && name[i] != '-' && name[i] != '_')
641 if (name[i] >= 'A' && name[i] <= 'Z')
643 // lowercase characters before '-'
644 pName[i] = (char) (((int)name[i]) + 0x20);
656 // this is not perfect to detect the non neutral cultures but it is good enough when we are running in invariant mode
657 isNeutralName = false;
660 while (i < name.Length)
662 if (name[i] >= 'a' && name[i] <= 'z')
664 pName[i] = (char) (((int)name[i]) - 0x20);
675 return new string(pName, 0, name.Length);
680 private static CultureData CreateCultureData(string cultureName, bool useUserOverride)
682 if (GlobalizationMode.Invariant)
684 CultureInfo.VerifyCultureName(cultureName, true);
685 CultureData cd = CreateCultureWithInvariantData();
686 cd._bUseOverrides = useUserOverride;
687 cd._sName = NormalizeCultureName(cultureName, out cd._bNeutral);
688 cd._sRealName = cd._sName;
689 cd._sWindowsName = cd._sName;
690 cd._iLanguage = CultureInfo.LOCALE_CUSTOM_UNSPECIFIED;
695 CultureData culture = new CultureData();
696 culture._bUseOverrides = useUserOverride;
697 culture._sRealName = cultureName;
699 // Ask native code if that one's real
700 if (culture.InitCultureData() == false)
702 if (culture.InitCompatibilityCultureData() == false)
711 private bool InitCompatibilityCultureData()
713 // for compatibility handle the deprecated ids: zh-chs, zh-cht
714 string cultureName = _sRealName;
716 string fallbackCultureName;
717 string realCultureName;
718 switch (AnsiToLower(cultureName))
721 fallbackCultureName = "zh-Hans";
722 realCultureName = "zh-CHS";
725 fallbackCultureName = "zh-Hant";
726 realCultureName = "zh-CHT";
732 _sRealName = fallbackCultureName;
733 if (InitCultureData() == false)
738 _sName = realCultureName; // the name that goes back to the user
739 _sParent = fallbackCultureName;
744 // We'd rather people use the named version since this doesn't allow custom locales
745 internal static CultureData GetCultureData(int culture, bool bUseUserOverride)
747 string localeName = null;
748 CultureData retVal = null;
750 if (culture == CultureInfo.LOCALE_INVARIANT)
753 if (GlobalizationMode.Invariant)
755 // LCID is not supported in the InvariantMode
756 throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupported);
759 // Convert the lcid to a name, then use that
760 // Note that this will return neutral names (unlike Vista native API)
761 localeName = LCIDToLocaleName(culture);
763 if (!String.IsNullOrEmpty(localeName))
765 // Valid name, use it
766 retVal = GetCultureData(localeName, bUseUserOverride);
769 // If not successful, throw
771 throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupported);
773 // Return the one we found
777 ////////////////////////////////////////////////////////////////////////
781 // Accessors for our data object items
783 ////////////////////////////////////////////////////////////////////////
789 // The real name used to construct the locale (ie: de-DE_phoneb)
790 internal String CultureName
794 Debug.Assert(_sRealName != null, "[CultureData.CultureName] Expected _sRealName to be populated by already");
795 // since windows doesn't know about zh-CHS and zh-CHT,
796 // we leave sRealName == zh-Hanx but we still need to
797 // pretend that it was zh-CHX.
808 // Are overrides enabled?
809 internal bool UseUserOverride
813 return _bUseOverrides;
817 // locale name (ie: de-DE, NO sort information)
818 internal String SNAME
824 _sName = String.Empty;
830 // Parent name (which may be a custom locale/culture)
831 internal String SPARENT
835 if (_sParent == null)
837 // Ask using the real name, so that we get parents of neutrals
838 _sParent = GetLocaleInfo(_sRealName, LocaleStringData.ParentName);
844 // Localized pretty name for this locale (ie: Inglis (estados Unitos))
845 internal String SLOCALIZEDDISPLAYNAME
849 if (_sLocalizedDisplayName == null)
851 if (this.IsSupplementalCustomCulture)
853 if (this.IsNeutralCulture)
855 _sLocalizedDisplayName = this.SNATIVELANGUAGE;
859 _sLocalizedDisplayName = this.SNATIVEDISPLAYNAME;
866 const string ZH_CHT = "zh-CHT";
867 const string ZH_CHS = "zh-CHS";
869 if (SNAME.Equals(ZH_CHT, StringComparison.OrdinalIgnoreCase))
871 _sLocalizedDisplayName = GetLanguageDisplayName("zh-Hant");
873 else if (SNAME.Equals(ZH_CHS, StringComparison.OrdinalIgnoreCase))
875 _sLocalizedDisplayName = GetLanguageDisplayName("zh-Hans");
879 _sLocalizedDisplayName = GetLanguageDisplayName(SNAME);
887 // If it hasn't been found (Windows 8 and up), fallback to the system
888 if (String.IsNullOrEmpty(_sLocalizedDisplayName))
890 // If its neutral use the language name
891 if (this.IsNeutralCulture)
893 _sLocalizedDisplayName = this.SLOCALIZEDLANGUAGE;
897 // Usually the UI culture shouldn't be different than what we got from WinRT except
898 // if DefaultThreadCurrentUICulture was set
901 if (CultureInfo.DefaultThreadCurrentUICulture != null &&
902 ((ci = GetUserDefaultCulture()) != null) &&
903 !CultureInfo.DefaultThreadCurrentUICulture.Name.Equals(ci.Name))
905 _sLocalizedDisplayName = this.SNATIVEDISPLAYNAME;
909 _sLocalizedDisplayName = GetLocaleInfo(LocaleStringData.LocalizedDisplayName);
915 return _sLocalizedDisplayName;
919 // English pretty name for this locale (ie: English (United States))
920 internal String SENGDISPLAYNAME
924 if (_sEnglishDisplayName == null)
926 // If its neutral use the language name
927 if (this.IsNeutralCulture)
929 _sEnglishDisplayName = this.SENGLISHLANGUAGE;
930 // differentiate the legacy display names
935 _sEnglishDisplayName += " Legacy";
941 _sEnglishDisplayName = GetLocaleInfo(LocaleStringData.EnglishDisplayName);
943 // if it isn't found build one:
944 if (String.IsNullOrEmpty(_sEnglishDisplayName))
946 // Our existing names mostly look like:
947 // "English" + "United States" -> "English (United States)"
948 // "Azeri (Latin)" + "Azerbaijan" -> "Azeri (Latin, Azerbaijan)"
949 if (this.SENGLISHLANGUAGE[this.SENGLISHLANGUAGE.Length - 1] == ')')
951 // "Azeri (Latin)" + "Azerbaijan" -> "Azeri (Latin, Azerbaijan)"
952 _sEnglishDisplayName =
953 this.SENGLISHLANGUAGE.Substring(0, _sEnglishLanguage.Length - 1) +
954 ", " + this.SENGCOUNTRY + ")";
958 // "English" + "United States" -> "English (United States)"
959 _sEnglishDisplayName = this.SENGLISHLANGUAGE + " (" + this.SENGCOUNTRY + ")";
964 return _sEnglishDisplayName;
968 // Native pretty name for this locale (ie: Deutsch (Deutschland))
969 internal String SNATIVEDISPLAYNAME
973 if (_sNativeDisplayName == null)
975 // If its neutral use the language name
976 if (this.IsNeutralCulture)
978 _sNativeDisplayName = this.SNATIVELANGUAGE;
979 // differentiate the legacy display names
983 _sNativeDisplayName += " \u65E7\u7248";
986 _sNativeDisplayName += " \u820A\u7248";
992 _sNativeDisplayName = GetLocaleInfo(LocaleStringData.NativeDisplayName);
994 // if it isn't found build one:
995 if (String.IsNullOrEmpty(_sNativeDisplayName))
997 // These should primarily be "Deutsch (Deutschland)" type names
998 _sNativeDisplayName = this.SNATIVELANGUAGE + " (" + this.SNATIVECOUNTRY + ")";
1002 return _sNativeDisplayName;
1006 // The culture name to be used in CultureInfo.CreateSpecificCulture()
1007 internal string SSPECIFICCULTURE
1011 // This got populated during the culture initialization
1012 Debug.Assert(_sSpecificCulture != null, "[CultureData.SSPECIFICCULTURE] Expected this.sSpecificCulture to be populated by culture data initialization already");
1013 return _sSpecificCulture;
1021 // iso 639 language name, ie: en
1022 internal String SISO639LANGNAME
1026 if (_sISO639Language == null)
1028 _sISO639Language = GetLocaleInfo(LocaleStringData.Iso639LanguageTwoLetterName);
1030 return _sISO639Language;
1034 // iso 639 language name, ie: eng
1035 internal string SISO639LANGNAME2
1039 if (_sISO639Language2 == null)
1041 _sISO639Language2 = GetLocaleInfo(LocaleStringData.Iso639LanguageThreeLetterName);
1043 return _sISO639Language2;
1047 // abbreviated windows language name (ie: enu) (non-standard, avoid this)
1048 internal string SABBREVLANGNAME
1052 if (_sAbbrevLang == null)
1054 _sAbbrevLang = GetThreeLetterWindowsLanguageName(_sRealName);
1056 return _sAbbrevLang;
1060 // Localized name for this language (Windows Only) ie: Inglis
1061 // This is only valid for Windows 8 and higher neutrals:
1062 internal String SLOCALIZEDLANGUAGE
1066 if (_sLocalizedLanguage == null)
1068 // Usually the UI culture shouldn't be different than what we got from WinRT except
1069 // if DefaultThreadCurrentUICulture was set
1072 if (CultureInfo.DefaultThreadCurrentUICulture != null &&
1073 ((ci = GetUserDefaultCulture()) != null) &&
1074 !CultureInfo.DefaultThreadCurrentUICulture.Name.Equals(ci.Name))
1076 _sLocalizedLanguage = SNATIVELANGUAGE;
1080 _sLocalizedLanguage = GetLocaleInfo(LocaleStringData.LocalizedLanguageName);
1084 return _sLocalizedLanguage;
1088 // English name for this language (Windows Only) ie: German
1089 internal String SENGLISHLANGUAGE
1093 if (_sEnglishLanguage == null)
1095 _sEnglishLanguage = GetLocaleInfo(LocaleStringData.EnglishLanguageName);
1097 return _sEnglishLanguage;
1101 // Native name of this language (Windows Only) ie: Deutsch
1102 internal String SNATIVELANGUAGE
1106 if (_sNativeLanguage == null)
1108 _sNativeLanguage = GetLocaleInfo(LocaleStringData.NativeLanguageName);
1110 return _sNativeLanguage;
1118 // region name (eg US)
1119 internal String SREGIONNAME
1123 if (_sRegionName == null)
1125 _sRegionName = GetLocaleInfo(LocaleStringData.Iso3166CountryName);
1127 return _sRegionName;
1135 if (_iGeoId == undef)
1137 _iGeoId = GetGeoId(_sRealName);
1143 // localized name for the country
1144 internal string SLOCALIZEDCOUNTRY
1148 if (_sLocalizedCountry == null)
1152 _sLocalizedCountry = GetRegionDisplayName(SISO3166CTRYNAME);
1156 // do nothing. we'll fallback
1159 if (_sLocalizedCountry == null)
1161 _sLocalizedCountry = SNATIVECOUNTRY;
1164 return _sLocalizedCountry;
1168 // english country name (RegionInfo) ie: Germany
1169 internal String SENGCOUNTRY
1173 if (_sEnglishCountry == null)
1175 _sEnglishCountry = GetLocaleInfo(LocaleStringData.EnglishCountryName);
1177 return _sEnglishCountry;
1181 // native country name (RegionInfo) ie: Deutschland
1182 internal String SNATIVECOUNTRY
1186 if (_sNativeCountry == null)
1188 _sNativeCountry = GetLocaleInfo(LocaleStringData.NativeCountryName);
1190 return _sNativeCountry;
1194 // ISO 3166 Country Name
1195 internal String SISO3166CTRYNAME
1199 if (_sISO3166CountryName == null)
1201 _sISO3166CountryName = GetLocaleInfo(LocaleStringData.Iso3166CountryName);
1203 return _sISO3166CountryName;
1207 // 3 letter ISO 3166 country code
1208 internal String SISO3166CTRYNAME2
1212 if (_sISO3166CountryName2 == null)
1214 _sISO3166CountryName2 = GetLocaleInfo(LocaleStringData.Iso3166CountryName2);
1216 return _sISO3166CountryName2;
1220 internal int IINPUTLANGUAGEHANDLE
1224 if (_iInputLanguageHandle == undef)
1226 if (IsSupplementalCustomCulture)
1228 _iInputLanguageHandle = 0x0409;
1232 // Input Language is same as LCID for built-in cultures
1233 _iInputLanguageHandle = this.ILANGUAGE;
1236 return _iInputLanguageHandle;
1240 // Console fallback name (ie: locale to use for console apps for unicode-only locales)
1241 internal string SCONSOLEFALLBACKNAME
1245 if (_sConsoleFallbackName == null)
1247 _sConsoleFallbackName = GetConsoleFallbackName(_sRealName);
1249 return _sConsoleFallbackName;
1253 // (user can override) grouping of digits
1254 internal int[] WAGROUPING
1258 if (_waGrouping == null)
1260 _waGrouping = GetLocaleInfo(LocaleGroupingData.Digit);
1267 // internal String sDecimalSeparator ; // (user can override) decimal separator
1268 // internal String sThousandSeparator ; // (user can override) thousands separator
1271 internal String SNAN
1277 _sNaN = GetLocaleInfo(LocaleStringData.NaNSymbol);
1284 internal String SPOSINFINITY
1288 if (_sPositiveInfinity == null)
1290 _sPositiveInfinity = GetLocaleInfo(LocaleStringData.PositiveInfinitySymbol);
1292 return _sPositiveInfinity;
1297 internal String SNEGINFINITY
1301 if (_sNegativeInfinity == null)
1303 _sNegativeInfinity = GetLocaleInfo(LocaleStringData.NegativeInfinitySymbol);
1305 return _sNegativeInfinity;
1314 // Negative Percent (0-3)
1315 internal int INEGATIVEPERCENT
1319 if (_iNegativePercent == undef)
1321 // Note that <= Windows Vista this is synthesized by native code
1322 _iNegativePercent = GetLocaleInfo(LocaleNumberData.NegativePercentFormat);
1324 return _iNegativePercent;
1328 // Positive Percent (0-11)
1329 internal int IPOSITIVEPERCENT
1333 if (_iPositivePercent == undef)
1335 // Note that <= Windows Vista this is synthesized by native code
1336 _iPositivePercent = GetLocaleInfo(LocaleNumberData.PositivePercentFormat);
1338 return _iPositivePercent;
1342 // Percent (%) symbol
1343 internal String SPERCENT
1347 if (_sPercent == null)
1349 _sPercent = GetLocaleInfo(LocaleStringData.PercentSymbol);
1356 internal String SPERMILLE
1360 if (_sPerMille == null)
1362 _sPerMille = GetLocaleInfo(LocaleStringData.PerMilleSymbol);
1372 // (user can override) local monetary symbol, eg: $
1373 internal String SCURRENCY
1377 if (_sCurrency == null)
1379 _sCurrency = GetLocaleInfo(LocaleStringData.MonetarySymbol);
1385 // international monetary symbol (RegionInfo), eg: USD
1386 internal String SINTLSYMBOL
1390 if (_sIntlMonetarySymbol == null)
1392 _sIntlMonetarySymbol = GetLocaleInfo(LocaleStringData.Iso4217MonetarySymbol);
1394 return _sIntlMonetarySymbol;
1398 // English name for this currency (RegionInfo), eg: US Dollar
1399 internal String SENGLISHCURRENCY
1403 if (_sEnglishCurrency == null)
1405 _sEnglishCurrency = GetLocaleInfo(LocaleStringData.CurrencyEnglishName);
1407 return _sEnglishCurrency;
1411 // Native name for this currency (RegionInfo), eg: Schweiz Frank
1412 internal String SNATIVECURRENCY
1416 if (_sNativeCurrency == null)
1418 _sNativeCurrency = GetLocaleInfo(LocaleStringData.CurrencyNativeName);
1420 return _sNativeCurrency;
1424 // internal int iCurrencyDigits ; // (user can override) # local monetary fractional digits
1425 // internal int iCurrency ; // (user can override) positive currency format
1426 // internal int iNegativeCurrency ; // (user can override) negative currency format
1428 // (user can override) monetary grouping of digits
1429 internal int[] WAMONGROUPING
1433 if (_waMonetaryGrouping == null)
1435 _waMonetaryGrouping = GetLocaleInfo(LocaleGroupingData.Monetary);
1437 return _waMonetaryGrouping;
1441 // (user can override) system of measurement 0=metric, 1=US (RegionInfo)
1442 internal int IMEASURE
1446 if (_iMeasure == undef)
1448 _iMeasure = GetLocaleInfo(LocaleNumberData.MeasurementSystem);
1454 // (user can override) list Separator
1455 internal String SLIST
1459 if (_sListSeparator == null)
1461 _sListSeparator = GetLocaleInfo(LocaleStringData.ListSeparator);
1463 return _sListSeparator;
1468 ////////////////////////////
1469 // Calendar/Time (Gregorian) //
1470 ////////////////////////////
1472 // (user can override) AM designator
1473 internal String SAM1159
1477 if (_sAM1159 == null)
1479 _sAM1159 = GetLocaleInfo(LocaleStringData.AMDesignator);
1485 // (user can override) PM designator
1486 internal String SPM2359
1490 if (_sPM2359 == null)
1492 _sPM2359 = GetLocaleInfo(LocaleStringData.PMDesignator);
1498 // (user can override) time format
1499 internal String[] LongTimes
1503 if (_saLongTimes == null)
1505 Debug.Assert(!GlobalizationMode.Invariant);
1507 String[] longTimes = GetTimeFormats();
1508 if (longTimes == null || longTimes.Length == 0)
1510 _saLongTimes = Invariant._saLongTimes;
1514 _saLongTimes = longTimes;
1517 return _saLongTimes;
1521 // short time format
1522 // Short times (derived from long times format)
1523 // TODO: NLS Arrowhead - On Windows 7 we should have short times so this isn't necessary
1524 internal String[] ShortTimes
1528 if (_saShortTimes == null)
1530 Debug.Assert(!GlobalizationMode.Invariant);
1532 // Try to get the short times from the OS/culture.dll
1533 String[] shortTimes = null;
1534 shortTimes = GetShortTimeFormats();
1536 if (shortTimes == null || shortTimes.Length == 0)
1539 // If we couldn't find short times, then compute them from long times
1540 // (eg: CORECLR on < Win7 OS & fallback for missing culture.dll)
1542 shortTimes = DeriveShortTimesFromLong();
1545 /* The above logic doesn't make sense on Mac, since the OS can provide us a "short time pattern".
1546 * currently this is the 4th element in the array returned by LongTimes. We'll add this to our array
1547 * if it doesn't exist.
1549 shortTimes = AdjustShortTimesForMac(shortTimes);
1551 // Found short times, use them
1552 _saShortTimes = shortTimes;
1554 return _saShortTimes;
1558 private string[] AdjustShortTimesForMac(string[] shortTimes)
1563 private string[] DeriveShortTimesFromLong()
1565 // Our logic is to look for h,H,m,s,t. If we find an s, then we check the string
1566 // between it and the previous marker, if any. If its a short, unescaped separator,
1567 // then we don't retain that part.
1568 // We then check after the ss and remove anything before the next h,H,m,t...
1569 string[] shortTimes = new string[LongTimes.Length];
1571 for (int i = 0; i < LongTimes.Length; i++)
1573 shortTimes[i] = StripSecondsFromPattern(LongTimes[i]);
1578 private static string StripSecondsFromPattern(string time)
1580 bool bEscape = false;
1581 int iLastToken = -1;
1584 for (int j = 0; j < time.Length; j++)
1586 // Change escape mode?
1587 if (time[j] == '\'')
1594 // See if there was a single \
1595 if (time[j] == '\\')
1609 // Check for seconds
1611 // Found seconds, see if there was something unescaped and short between
1612 // the last marker and the seconds. Windows says separator can be a
1613 // maximum of three characters (without null)
1614 // If 1st or last characters were ', then ignore it
1615 if ((j - iLastToken) <= 4 && (j - iLastToken) > 1 &&
1616 (time[iLastToken + 1] != '\'') &&
1617 (time[j - 1] != '\''))
1619 // There was something there we want to remember
1620 if (iLastToken >= 0)
1627 int endIndex = GetIndexOfNextTokenAfterSeconds(time, j, out containsSpace);
1640 time = time.Substring(0, j) + sep + time.Substring(endIndex);
1652 private static int GetIndexOfNextTokenAfterSeconds(string time, int index, out bool containsSpace)
1654 bool bEscape = false;
1655 containsSpace = false;
1656 for (; index < time.Length; index++)
1658 switch (time[index])
1665 if (time[index] == ' ')
1667 containsSpace = true;
1671 containsSpace = true;
1684 containsSpace = false;
1688 // (user can override) first day of week
1689 internal int IFIRSTDAYOFWEEK
1693 if (_iFirstDayOfWeek == undef)
1695 _iFirstDayOfWeek = GetFirstDayOfWeek();
1697 return _iFirstDayOfWeek;
1701 // (user can override) first week of year
1702 internal int IFIRSTWEEKOFYEAR
1706 if (_iFirstWeekOfYear == undef)
1708 _iFirstWeekOfYear = GetLocaleInfo(LocaleNumberData.FirstWeekOfYear);
1710 return _iFirstWeekOfYear;
1714 // (user can override default only) short date format
1715 internal String[] ShortDates(CalendarId calendarId)
1717 return GetCalendar(calendarId).saShortDates;
1720 // (user can override default only) long date format
1721 internal String[] LongDates(CalendarId calendarId)
1723 return GetCalendar(calendarId).saLongDates;
1726 // (user can override) date year/month format.
1727 internal String[] YearMonths(CalendarId calendarId)
1729 return GetCalendar(calendarId).saYearMonths;
1733 internal string[] DayNames(CalendarId calendarId)
1735 return GetCalendar(calendarId).saDayNames;
1738 // abbreviated day names
1739 internal string[] AbbreviatedDayNames(CalendarId calendarId)
1741 // Get abbreviated day names for this calendar from the OS if necessary
1742 return GetCalendar(calendarId).saAbbrevDayNames;
1745 // The super short day names
1746 internal string[] SuperShortDayNames(CalendarId calendarId)
1748 return GetCalendar(calendarId).saSuperShortDayNames;
1752 internal string[] MonthNames(CalendarId calendarId)
1754 return GetCalendar(calendarId).saMonthNames;
1757 // Genitive month names
1758 internal string[] GenitiveMonthNames(CalendarId calendarId)
1760 return GetCalendar(calendarId).saMonthGenitiveNames;
1764 internal string[] AbbreviatedMonthNames(CalendarId calendarId)
1766 return GetCalendar(calendarId).saAbbrevMonthNames;
1769 // Genitive month names
1770 internal string[] AbbreviatedGenitiveMonthNames(CalendarId calendarId)
1772 return GetCalendar(calendarId).saAbbrevMonthGenitiveNames;
1775 // Leap year month names
1776 // Note: This only applies to Hebrew, and it basically adds a "1" to the 6th month name
1777 // the non-leap names skip the 7th name in the normal month name array
1778 internal string[] LeapYearMonthNames(CalendarId calendarId)
1780 return GetCalendar(calendarId).saLeapYearMonthNames;
1783 // month/day format (single string, no override)
1784 internal String MonthDay(CalendarId calendarId)
1786 return GetCalendar(calendarId).sMonthDay;
1795 // all available calendar type(s), The first one is the default calendar.
1796 internal CalendarId[] CalendarIds
1800 if (_waCalendars == null)
1802 // We pass in an array of ints, and native side fills it up with count calendars.
1803 // We then have to copy that list to a new array of the right size.
1804 // Default calendar should be first
1805 CalendarId[] calendars = new CalendarId[23];
1806 Debug.Assert(_sWindowsName != null, "[CultureData.CalendarIds] Expected _sWindowsName to be populated by already");
1807 int count = CalendarData.GetCalendars(_sWindowsName, _bUseOverrides, calendars);
1809 // See if we had a calendar to add.
1812 // Failed for some reason, just grab Gregorian from Invariant
1813 _waCalendars = Invariant._waCalendars;
1817 // The OS may not return calendar 4 for zh-TW, but we've always allowed it.
1818 // TODO: Is this hack necessary long-term?
1819 if (_sWindowsName == "zh-TW")
1823 // Do we need to insert calendar 4?
1824 for (int i = 0; i < count; i++)
1826 // Stop if we found calendar four
1827 if (calendars[i] == CalendarId.TAIWAN)
1834 // If not found then insert it
1837 // Insert it as the 2nd calendar
1839 // Copy them from the 2nd position to the end, -1 for skipping 1st, -1 for one being added.
1840 Array.Copy(calendars, 1, calendars, 2, 23 - 1 - 1);
1841 calendars[1] = CalendarId.TAIWAN;
1845 // It worked, remember the list
1846 CalendarId[] temp = new CalendarId[count];
1847 Array.Copy(calendars, temp, count);
1849 // Want 1st calendar to be default
1850 // Prior to Vista the enumeration didn't have default calendar first
1851 if (temp.Length > 1)
1853 CalendarId i = (CalendarId)GetLocaleInfo(LocaleNumberData.CalendarType);
1861 _waCalendars = temp;
1865 return _waCalendars;
1869 // Native calendar names. index of optional calendar - 1, empty if no optional calendar at that number
1870 internal string CalendarName(CalendarId calendarId)
1873 return GetCalendar(calendarId).sNativeName;
1876 internal CalendarData GetCalendar(CalendarId calendarId)
1878 Debug.Assert(calendarId > 0 && calendarId <= CalendarId.LAST_CALENDAR,
1879 "[CultureData.GetCalendar] Expect calendarId to be in a valid range");
1881 // arrays are 0 based, calendarIds are 1 based
1882 int calendarIndex = (int)calendarId - 1;
1884 // Have to have calendars
1885 if (_calendars == null)
1887 _calendars = new CalendarData[CalendarData.MAX_CALENDARS];
1890 // we need the following local variable to avoid returning null
1891 // when another thread creates a new array of CalendarData (above)
1892 // right after we insert the newly created CalendarData (below)
1893 CalendarData calendarData = _calendars[calendarIndex];
1894 // Make sure that calendar has data
1895 if (calendarData == null)
1897 Debug.Assert(_sWindowsName != null, "[CultureData.GetCalendar] Expected _sWindowsName to be populated by already");
1898 calendarData = new CalendarData(_sWindowsName, calendarId, this.UseUserOverride);
1899 _calendars[calendarIndex] = calendarData;
1902 return calendarData;
1906 // Text Information //
1910 internal bool IsRightToLeft
1914 // Returns one of the following 4 reading layout values:
1915 // 0 - Left to right (eg en-US)
1916 // 1 - Right to left (eg arabic locales)
1917 // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
1918 // 3 - Vertical top to bottom with columns proceeding to the right
1919 return (this.IREADINGLAYOUT == 1);
1924 // Returns one of the following 4 reading layout values:
1925 // 0 - Left to right (eg en-US)
1926 // 1 - Right to left (eg arabic locales)
1927 // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
1928 // 3 - Vertical top to bottom with columns proceeding to the right
1930 // If exposed as a public API, we'd have an enum with those 4 values
1931 private int IREADINGLAYOUT
1935 if (_iReadingLayout == undef)
1937 Debug.Assert(_sRealName != null, "[CultureData.IsRightToLeft] Expected _sRealName to be populated by already");
1938 _iReadingLayout = GetLocaleInfo(LocaleNumberData.ReadingLayout);
1941 return (_iReadingLayout);
1945 // The TextInfo name never includes that alternate sort and is always specific
1946 // For customs, it uses the SortLocale (since the textinfo is not exposed in Win7)
1949 // fj (custom neutral) -> en-US (assuming that en-US is the sort locale for fj)
1950 // fj_FJ (custom specific) -> en-US (assuming that en-US is the sort locale for fj-FJ)
1951 // es-ES_tradnl -> es-ES
1952 internal String STEXTINFO // Text info name to use for text information
1956 // Note: Custom cultures might point at another culture's textinfo, however windows knows how
1957 // to redirect it to the desired textinfo culture, so this is OK.
1958 Debug.Assert(_sRealName != null, "[CultureData.STEXTINFO] Expected _sRealName to be populated by already");
1959 return (_sRealName);
1963 // Compare info name (including sorting key) to use if custom
1964 internal String SCOMPAREINFO
1968 Debug.Assert(_sRealName != null, "[CultureData.SCOMPAREINFO] Expected _sRealName to be populated by already");
1969 return (_sRealName);
1973 internal bool IsSupplementalCustomCulture
1977 return IsCustomCultureId(this.ILANGUAGE);
1981 internal int IDEFAULTANSICODEPAGE // default ansi code page ID (ACP)
1985 if (_iDefaultAnsiCodePage == undef)
1987 _iDefaultAnsiCodePage = GetAnsiCodePage(_sRealName);
1989 return _iDefaultAnsiCodePage;
1993 internal int IDEFAULTOEMCODEPAGE // default oem code page ID (OCP or OEM)
1997 if (_iDefaultOemCodePage == undef)
1999 _iDefaultOemCodePage = GetOemCodePage(_sRealName);
2001 return _iDefaultOemCodePage;
2005 internal int IDEFAULTMACCODEPAGE // default macintosh code page
2009 if (_iDefaultMacCodePage == undef)
2011 _iDefaultMacCodePage = GetMacCodePage(_sRealName);
2013 return _iDefaultMacCodePage;
2017 internal int IDEFAULTEBCDICCODEPAGE // default EBCDIC code page
2021 if (_iDefaultEbcdicCodePage == undef)
2023 _iDefaultEbcdicCodePage = GetEbcdicCodePage(_sRealName);
2025 return _iDefaultEbcdicCodePage;
2029 internal int ILANGUAGE
2033 if (_iLanguage == 0)
2035 Debug.Assert(_sRealName != null, "[CultureData.ILANGUAGE] Expected this.sRealName to be populated already");
2036 _iLanguage = LocaleNameToLCID(_sRealName);
2042 internal bool IsNeutralCulture
2046 // InitCultureData told us if we're neutral or not
2051 internal bool IsInvariantCulture
2055 return String.IsNullOrEmpty(this.SNAME);
2059 // Get an instance of our default calendar
2060 internal Calendar DefaultCalendar
2064 if (GlobalizationMode.Invariant)
2066 return CultureInfo.GetCalendarInstance(CalendarIds[0]);
2069 CalendarId defaultCalId = (CalendarId)GetLocaleInfo(LocaleNumberData.CalendarType);
2071 if (defaultCalId == 0)
2073 defaultCalId = this.CalendarIds[0];
2076 return CultureInfo.GetCalendarInstance(defaultCalId);
2080 // All of our era names
2081 internal String[] EraNames(CalendarId calendarId)
2083 Debug.Assert(calendarId > 0, "[CultureData.saEraNames] Expected Calendar.ID > 0");
2085 return this.GetCalendar(calendarId).saEraNames;
2088 internal String[] AbbrevEraNames(CalendarId calendarId)
2090 Debug.Assert(calendarId > 0, "[CultureData.saAbbrevEraNames] Expected Calendar.ID > 0");
2092 return this.GetCalendar(calendarId).saAbbrevEraNames;
2095 internal String[] AbbreviatedEnglishEraNames(CalendarId calendarId)
2097 Debug.Assert(calendarId > 0, "[CultureData.saAbbrevEraNames] Expected Calendar.ID > 0");
2099 return this.GetCalendar(calendarId).saAbbrevEnglishEraNames;
2102 //// String array DEFAULTS
2103 //// Note: GetDTFIOverrideValues does the user overrides for these, so we don't have to.
2106 // Time separator (derived from time format)
2107 internal String TimeSeparator
2111 if (_sTimeSeparator == null)
2113 string longTimeFormat = GetTimeFormatString();
2114 if (String.IsNullOrEmpty(longTimeFormat))
2116 longTimeFormat = LongTimes[0];
2119 // Compute STIME from time format
2120 _sTimeSeparator = GetTimeSeparator(longTimeFormat);
2122 return _sTimeSeparator;
2126 // Date separator (derived from short date format)
2127 internal String DateSeparator(CalendarId calendarId)
2129 return GetDateSeparator(ShortDates(calendarId)[0]);
2132 //////////////////////////////////////
2133 // Helper Functions to get derived properties //
2134 //////////////////////////////////////
2136 ////////////////////////////////////////////////////////////////////////////
2138 // Unescape a NLS style quote string
2140 // This removes single quotes:
2146 // This removes the first \ of escaped characters:
2147 // fred\'s -> fred's
2151 // We don't build the stringbuilder unless we find a ' or a \. If we find a ' or a \, we
2152 // always build a stringbuilder because we need to remove the ' or \.
2154 ////////////////////////////////////////////////////////////////////////////
2155 private static String UnescapeNlsString(String str, int start, int end)
2157 Debug.Assert(str != null);
2158 Debug.Assert(start >= 0);
2159 Debug.Assert(end >= 0);
2160 StringBuilder result = null;
2162 for (int i = start; i < str.Length && i <= end; i++)
2169 result = new StringBuilder(str, start, i - start, str.Length);
2175 result = new StringBuilder(str, start, i - start, str.Length);
2180 result.Append(str[i]);
2186 result.Append(str[i]);
2193 return (str.Substring(start, end - start + 1));
2195 return (result.ToString());
2198 private static String GetTimeSeparator(String format)
2200 // Time format separator (ie: : in 12:39:00)
2202 // We calculate this from the provided time format
2206 // Find the time separator so that we can pretend we know STIME.
2208 return GetSeparator(format, "Hhms");
2211 private static String GetDateSeparator(String format)
2213 // Date format separator (ie: / in 9/1/03)
2215 // We calculate this from the provided short date
2219 // Find the date separator so that we can pretend we know SDATE.
2221 return GetSeparator(format, "dyM");
2224 private static string GetSeparator(string format, string timeParts)
2226 int index = IndexOfTimePart(format, 0, timeParts);
2230 // Found a time part, find out when it changes
2231 char cTimePart = format[index];
2236 } while (index < format.Length && format[index] == cTimePart);
2238 int separatorStart = index;
2240 // Now we need to find the end of the separator
2241 if (separatorStart < format.Length)
2243 int separatorEnd = IndexOfTimePart(format, separatorStart, timeParts);
2244 if (separatorEnd != -1)
2246 // From [separatorStart, count) is our string, except we need to unescape
2247 return UnescapeNlsString(format, separatorStart, separatorEnd - 1);
2252 return String.Empty;
2255 private static int IndexOfTimePart(string format, int startIndex, string timeParts)
2257 Debug.Assert(startIndex >= 0, "startIndex cannot be negative");
2258 Debug.Assert(timeParts.IndexOfAny(new char[] { '\'', '\\' }) == -1, "timeParts cannot include quote characters");
2259 bool inQuote = false;
2260 for (int i = startIndex; i < format.Length; ++i)
2262 // See if we have a time Part
2263 if (!inQuote && timeParts.IndexOf(format[i]) != -1)
2270 if (i + 1 < format.Length)
2279 --i; //backup since we will move over this next
2293 internal static bool IsCustomCultureId(int cultureId)
2295 return (cultureId == CultureInfo.LOCALE_CUSTOM_DEFAULT || cultureId == CultureInfo.LOCALE_CUSTOM_UNSPECIFIED);
2298 internal void GetNFIValues(NumberFormatInfo nfi)
2300 if (GlobalizationMode.Invariant || this.IsInvariantCulture)
2302 // FUTURE: NumberFormatInfo already has default values for many of these fields. Can we not do this?
2303 nfi.positiveSign = _sPositiveSign;
2304 nfi.negativeSign = _sNegativeSign;
2306 nfi.numberGroupSeparator = _sThousandSeparator;
2307 nfi.numberDecimalSeparator = _sDecimalSeparator;
2308 nfi.numberDecimalDigits = _iDigits;
2309 nfi.numberNegativePattern = _iNegativeNumber;
2311 nfi.currencySymbol = _sCurrency;
2312 nfi.currencyGroupSeparator = _sMonetaryThousand;
2313 nfi.currencyDecimalSeparator = _sMonetaryDecimal;
2314 nfi.currencyDecimalDigits = _iCurrencyDigits;
2315 nfi.currencyNegativePattern = _iNegativeCurrency;
2316 nfi.currencyPositivePattern = _iCurrency;
2320 Debug.Assert(_sWindowsName != null, "[CultureData.GetNFIValues] Expected _sWindowsName to be populated by already");
2322 nfi.positiveSign = GetLocaleInfo(LocaleStringData.PositiveSign);
2323 nfi.negativeSign = GetLocaleInfo(LocaleStringData.NegativeSign);
2325 nfi.numberDecimalSeparator = GetLocaleInfo(LocaleStringData.DecimalSeparator);
2326 nfi.numberGroupSeparator = GetLocaleInfo(LocaleStringData.ThousandSeparator);
2327 nfi.currencyGroupSeparator = GetLocaleInfo(LocaleStringData.MonetaryThousandSeparator);
2328 nfi.currencyDecimalSeparator = GetLocaleInfo(LocaleStringData.MonetaryDecimalSeparator);
2329 nfi.currencySymbol = GetLocaleInfo(LocaleStringData.MonetarySymbol);
2332 nfi.numberDecimalDigits = GetLocaleInfo(LocaleNumberData.FractionalDigitsCount);
2333 nfi.currencyDecimalDigits = GetLocaleInfo(LocaleNumberData.MonetaryFractionalDigitsCount);
2334 nfi.currencyPositivePattern = GetLocaleInfo(LocaleNumberData.PositiveMonetaryNumberFormat);
2335 nfi.currencyNegativePattern = GetLocaleInfo(LocaleNumberData.NegativeMonetaryNumberFormat);
2336 nfi.numberNegativePattern = GetLocaleInfo(LocaleNumberData.NegativeNumberFormat);
2338 // LOCALE_SNATIVEDIGITS (array of 10 single character strings).
2339 string digits = GetLocaleInfo(LocaleStringData.Digits);
2340 nfi.nativeDigits = new string[10];
2341 for (int i = 0; i < nfi.nativeDigits.Length; i++)
2343 nfi.nativeDigits[i] = new string(digits[i], 1);
2346 nfi.digitSubstitution = GetDigitSubstitution(_sRealName);
2350 // Gather additional data
2352 nfi.numberGroupSizes = this.WAGROUPING;
2353 nfi.currencyGroupSizes = this.WAMONGROUPING;
2355 // prefer the cached value since these do not have user overrides
2356 nfi.percentNegativePattern = this.INEGATIVEPERCENT;
2357 nfi.percentPositivePattern = this.IPOSITIVEPERCENT;
2358 nfi.percentSymbol = this.SPERCENT;
2359 nfi.perMilleSymbol = this.SPERMILLE;
2361 nfi.negativeInfinitySymbol = this.SNEGINFINITY;
2362 nfi.positiveInfinitySymbol = this.SPOSINFINITY;
2363 nfi.nanSymbol = this.SNAN;
2366 // We don't have percent values, so use the number values
2368 nfi.percentDecimalDigits = nfi.numberDecimalDigits;
2369 nfi.percentDecimalSeparator = nfi.numberDecimalSeparator;
2370 nfi.percentGroupSizes = nfi.numberGroupSizes;
2371 nfi.percentGroupSeparator = nfi.numberGroupSeparator;
2374 // Clean up a few odd values
2377 // Windows usually returns an empty positive sign, but we like it to be "+"
2378 if (nfi.positiveSign == null || nfi.positiveSign.Length == 0) nfi.positiveSign = "+";
2380 //Special case for Italian. The currency decimal separator in the control panel is the empty string. When the user
2381 //specifies C4 as the currency format, this results in the number apparently getting multiplied by 10000 because the
2382 //decimal point doesn't show up. We'll just hack this here because our default currency format will never use nfi.
2383 if (nfi.currencyDecimalSeparator == null || nfi.currencyDecimalSeparator.Length == 0)
2385 nfi.currencyDecimalSeparator = nfi.numberDecimalSeparator;
2390 // This is ONLY used for caching names and shouldn't be used for anything else
2391 internal static string AnsiToLower(string testString)
2395 while (index<testString.Length && (testString[index]<'A' || testString[index]>'Z' ))
2399 if (index >= testString.Length)
2401 return testString; // we didn't really change the string
2404 StringBuilder sb = new StringBuilder(testString.Length);
2405 for (int i=0; i<index; i++)
2407 sb.Append(testString[i]);
2410 sb.Append((char) (testString[index] -'A' + 'a'));
2412 for (int ich = index+1; ich < testString.Length; ich++)
2414 char ch = testString[ich];
2415 sb.Append(ch <= 'Z' && ch >= 'A' ? (char)(ch - 'A' + 'a') : ch);
2418 return (sb.ToString());
2422 /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementation
2423 /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to LCTypes.
2425 private enum LocaleStringData : uint
2427 /// <summary>localized name of locale, eg "German (Germany)" in UI language (corresponds to LOCALE_SLOCALIZEDDISPLAYNAME)</summary>
2428 LocalizedDisplayName = 0x00000002,
2429 /// <summary>Display name (language + country usually) in English, eg "German (Germany)" (corresponds to LOCALE_SENGLISHDISPLAYNAME)</summary>
2430 EnglishDisplayName = 0x00000072,
2431 /// <summary>Display name in native locale language, eg "Deutsch (Deutschland) (corresponds to LOCALE_SNATIVEDISPLAYNAME)</summary>
2432 NativeDisplayName = 0x00000073,
2433 /// <summary>Language Display Name for a language, eg "German" in UI language (corresponds to LOCALE_SLOCALIZEDLANGUAGENAME)</summary>
2434 LocalizedLanguageName = 0x0000006f,
2435 /// <summary>English name of language, eg "German" (corresponds to LOCALE_SENGLISHLANGUAGENAME)</summary>
2436 EnglishLanguageName = 0x00001001,
2437 /// <summary>native name of language, eg "Deutsch" (corresponds to LOCALE_SNATIVELANGUAGENAME)</summary>
2438 NativeLanguageName = 0x00000004,
2439 /// <summary>localized name of country, eg "Germany" in UI language (corresponds to LOCALE_SLOCALIZEDCOUNTRYNAME)</summary>
2440 LocalizedCountryName = 0x00000006,
2441 /// <summary>English name of country, eg "Germany" (corresponds to LOCALE_SENGLISHCOUNTRYNAME)</summary>
2442 EnglishCountryName = 0x00001002,
2443 /// <summary>native name of country, eg "Deutschland" (corresponds to LOCALE_SNATIVECOUNTRYNAME)</summary>
2444 NativeCountryName = 0x00000008,
2445 /// <summary>abbreviated language name (corresponds to LOCALE_SABBREVLANGNAME)</summary>
2446 AbbreviatedWindowsLanguageName = 0x00000003,
2447 /// <summary>list item separator (corresponds to LOCALE_SLIST)</summary>
2448 ListSeparator = 0x0000000C,
2449 /// <summary>decimal separator (corresponds to LOCALE_SDECIMAL)</summary>
2450 DecimalSeparator = 0x0000000E,
2451 /// <summary>thousand separator (corresponds to LOCALE_STHOUSAND)</summary>
2452 ThousandSeparator = 0x0000000F,
2453 /// <summary>digit grouping (corresponds to LOCALE_SGROUPING)</summary>
2454 Digits = 0x00000013,
2455 /// <summary>local monetary symbol (corresponds to LOCALE_SCURRENCY)</summary>
2456 MonetarySymbol = 0x00000014,
2457 /// <summary>English currency name (corresponds to LOCALE_SENGCURRNAME)</summary>
2458 CurrencyEnglishName = 0x00001007,
2459 /// <summary>Native currency name (corresponds to LOCALE_SNATIVECURRNAME)</summary>
2460 CurrencyNativeName = 0x00001008,
2461 /// <summary>uintl monetary symbol (corresponds to LOCALE_SINTLSYMBOL)</summary>
2462 Iso4217MonetarySymbol = 0x00000015,
2463 /// <summary>monetary decimal separator (corresponds to LOCALE_SMONDECIMALSEP)</summary>
2464 MonetaryDecimalSeparator = 0x00000016,
2465 /// <summary>monetary thousand separator (corresponds to LOCALE_SMONTHOUSANDSEP)</summary>
2466 MonetaryThousandSeparator = 0x00000017,
2467 /// <summary>AM designator (corresponds to LOCALE_S1159)</summary>
2468 AMDesignator = 0x00000028,
2469 /// <summary>PM designator (corresponds to LOCALE_S2359)</summary>
2470 PMDesignator = 0x00000029,
2471 /// <summary>positive sign (corresponds to LOCALE_SPOSITIVESIGN)</summary>
2472 PositiveSign = 0x00000050,
2473 /// <summary>negative sign (corresponds to LOCALE_SNEGATIVESIGN)</summary>
2474 NegativeSign = 0x00000051,
2475 /// <summary>ISO abbreviated language name (corresponds to LOCALE_SISO639LANGNAME)</summary>
2476 Iso639LanguageTwoLetterName = 0x00000059,
2477 /// <summary>ISO abbreviated country name (corresponds to LOCALE_SISO639LANGNAME2)</summary>
2478 Iso639LanguageThreeLetterName = 0x00000067,
2479 /// <summary>ISO abbreviated language name (corresponds to LOCALE_SISO639LANGNAME)</summary>
2480 Iso639LanguageName = 0x00000059,
2481 /// <summary>ISO abbreviated country name (corresponds to LOCALE_SISO3166CTRYNAME)</summary>
2482 Iso3166CountryName = 0x0000005A,
2483 /// <summary>3 letter ISO country code (corresponds to LOCALE_SISO3166CTRYNAME2)</summary>
2484 Iso3166CountryName2 = 0x00000068, // 3 character ISO country name
2485 /// <summary>Not a Number (corresponds to LOCALE_SNAN)</summary>
2486 NaNSymbol = 0x00000069,
2487 /// <summary>+ Infinity (corresponds to LOCALE_SPOSINFINITY)</summary>
2488 PositiveInfinitySymbol = 0x0000006a,
2489 /// <summary>- Infinity (corresponds to LOCALE_SNEGINFINITY)</summary>
2490 NegativeInfinitySymbol = 0x0000006b,
2491 /// <summary>Fallback name for resources (corresponds to LOCALE_SPARENT)</summary>
2492 ParentName = 0x0000006d,
2493 /// <summary>Fallback name for within the console (corresponds to LOCALE_SCONSOLEFALLBACKNAME)</summary>
2494 ConsoleFallbackName = 0x0000006e,
2495 /// <summary>Returns the percent symbol (corresponds to LOCALE_SPERCENT)</summary>
2496 PercentSymbol = 0x00000076,
2497 /// <summary>Returns the permille (U+2030) symbol (corresponds to LOCALE_SPERMILLE)</summary>
2498 PerMilleSymbol = 0x00000077
2502 /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementation
2503 /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to LCTypes.
2505 private enum LocaleGroupingData : uint
2507 /// <summary>digit grouping (corresponds to LOCALE_SGROUPING)</summary>
2509 /// <summary>monetary grouping (corresponds to LOCALE_SMONGROUPING)</summary>
2510 Monetary = 0x00000018,
2514 /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementation
2515 /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to LCTypes.
2517 private enum LocaleNumberData : uint
2519 /// <summary>language id (corresponds to LOCALE_ILANGUAGE)</summary>
2520 LanguageId = 0x00000001,
2521 /// <summary>geographical location id, (corresponds to LOCALE_IGEOID)</summary>
2523 /// <summary>0 = context, 1 = none, 2 = national (corresponds to LOCALE_IDIGITSUBSTITUTION)</summary>
2524 DigitSubstitution = 0x00001014,
2525 /// <summary>0 = metric, 1 = US (corresponds to LOCALE_IMEASURE)</summary>
2526 MeasurementSystem = 0x0000000D,
2527 /// <summary>number of fractional digits (corresponds to LOCALE_IDIGITS)</summary>
2528 FractionalDigitsCount = 0x00000011,
2529 /// <summary>negative number mode (corresponds to LOCALE_INEGNUMBER)</summary>
2530 NegativeNumberFormat = 0x00001010,
2531 /// <summary># local monetary digits (corresponds to LOCALE_ICURRDIGITS)</summary>
2532 MonetaryFractionalDigitsCount = 0x00000019,
2533 /// <summary>positive currency mode (corresponds to LOCALE_ICURRENCY)</summary>
2534 PositiveMonetaryNumberFormat = 0x0000001B,
2535 /// <summary>negative currency mode (corresponds to LOCALE_INEGCURR)</summary>
2536 NegativeMonetaryNumberFormat = 0x0000001C,
2537 /// <summary>type of calendar specifier (corresponds to LOCALE_ICALENDARTYPE)</summary>
2538 CalendarType = 0x00001009,
2539 /// <summary>first day of week specifier (corresponds to LOCALE_IFIRSTDAYOFWEEK)</summary>
2540 FirstDayOfWeek = 0x0000100C,
2541 /// <summary>first week of year specifier (corresponds to LOCALE_IFIRSTWEEKOFYEAR)</summary>
2542 FirstWeekOfYear = 0x0000100D,
2544 /// Returns one of the following 4 reading layout values:
2545 /// 0 - Left to right (eg en-US)
2546 /// 1 - Right to left (eg arabic locales)
2547 /// 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
2548 /// 3 - Vertical top to bottom with columns proceeding to the right
2549 /// (corresponds to LOCALE_IREADINGLAYOUT)
2551 ReadingLayout = 0x00000070,
2552 /// <summary>Returns 0-11 for the negative percent format (corresponds to LOCALE_INEGATIVEPERCENT)</summary>
2553 NegativePercentFormat = 0x00000074,
2554 /// <summary>Returns 0-3 for the positive percent format (corresponds to LOCALE_IPOSITIVEPERCENT)</summary>
2555 PositivePercentFormat = 0x00000075,
2556 /// <summary>default ansi code page (corresponds to LOCALE_IDEFAULTCODEPAGE)</summary>
2557 OemCodePage = 0x0000000B,
2558 /// <summary>default ansi code page (corresponds to LOCALE_IDEFAULTANSICODEPAGE)</summary>
2559 AnsiCodePage = 0x00001004,
2560 /// <summary>default mac code page (corresponds to LOCALE_IDEFAULTMACCODEPAGE)</summary>
2561 MacCodePage = 0x00001011,
2562 /// <summary>default ebcdic code page (corresponds to LOCALE_IDEFAULTEBCDICCODEPAGE)</summary>
2563 EbcdicCodePage = 0x00001012,