| | | 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 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Diagnostics; |
| | | 6 | | using System.Text; |
| | | 7 | | using System.Threading; |
| | | 8 | | |
| | | 9 | | namespace System.Globalization |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// List of culture data |
| | | 13 | | /// Note the we cache overrides. |
| | | 14 | | /// Note that localized names (resource names) aren't available from here. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <remarks> |
| | | 17 | | /// Our names are a tad confusing. |
| | | 18 | | /// |
| | | 19 | | /// sWindowsName -- The name that windows thinks this culture is, ie: |
| | | 20 | | /// en-US if you pass in en-US |
| | | 21 | | /// de-DE_phoneb if you pass in de-DE_phoneb |
| | | 22 | | /// fj-FJ if you pass in fj (neutral, on a pre-Windows 7 machine) |
| | | 23 | | /// fj if you pass in fj (neutral, post-Windows 7 machine) |
| | | 24 | | /// |
| | | 25 | | /// sRealName -- The name you used to construct the culture, in pretty form |
| | | 26 | | /// en-US if you pass in EN-us |
| | | 27 | | /// en if you pass in en |
| | | 28 | | /// de-DE_phoneb if you pass in de-DE_phoneb |
| | | 29 | | /// |
| | | 30 | | /// sSpecificCulture -- The specific culture for this culture |
| | | 31 | | /// en-US for en-US |
| | | 32 | | /// en-US for en |
| | | 33 | | /// de-DE_phoneb for alt sort |
| | | 34 | | /// fj-FJ for fj (neutral) |
| | | 35 | | /// |
| | | 36 | | /// sName -- The IETF name of this culture (ie: no sort info, could be neutral) |
| | | 37 | | /// en-US if you pass in en-US |
| | | 38 | | /// en if you pass in en |
| | | 39 | | /// de-DE if you pass in de-DE_phoneb |
| | | 40 | | /// </remarks> |
| | | 41 | | internal sealed partial class CultureData |
| | | 42 | | { |
| | | 43 | | private const int LocaleNameMaxLength = 85; |
| | | 44 | | private const int undef = -1; |
| | | 45 | | |
| | | 46 | | // Override flag |
| | | 47 | | private string _sRealName = null!; // Name you passed in (ie: en-US, en, or de-DE_phoneb). Initialized by helper |
| | | 48 | | private string? _sWindowsName; // Name OS thinks the object is (ie: de-DE_phoneb, or en-US (even if en was passe |
| | | 49 | | |
| | | 50 | | // Identity |
| | | 51 | | private string? _sName; // locale name (ie: en-us, NO sort info, but could be neutral) |
| | | 52 | | private string? _sParent; // Parent name (which may be a custom locale/culture) |
| | | 53 | | private string? _sEnglishDisplayName; // English pretty name for this locale |
| | | 54 | | private string? _sNativeDisplayName; // Native pretty name for this locale |
| | | 55 | | private string? _sSpecificCulture; // The culture name to be used in CultureInfo.CreateSpecificCulture(), en-US |
| | | 56 | | |
| | | 57 | | // Language |
| | | 58 | | private string? _sISO639Language; // ISO 639 Language Name |
| | | 59 | | private string? _sISO639Language2; // ISO 639 Language Name |
| | | 60 | | private string? _sEnglishLanguage; // English name for this language |
| | | 61 | | private string? _sNativeLanguage; // Native name of this language |
| | | 62 | | private string? _sAbbrevLang; // abbreviated language name (Windows Language Name) ex: ENU |
| | | 63 | | private string? _sConsoleFallbackName; // The culture name for the console fallback UI culture |
| | 0 | 64 | | private int _iInputLanguageHandle = undef; // input language handle |
| | | 65 | | |
| | | 66 | | // Region |
| | | 67 | | private string? _sRegionName; // (RegionInfo) |
| | | 68 | | private string? _sLocalizedCountry; // localized country name |
| | | 69 | | private string? _sEnglishCountry; // english country name (RegionInfo) |
| | | 70 | | private string? _sNativeCountry; // native country name |
| | | 71 | | private string? _sISO3166CountryName; // ISO 3166 (RegionInfo), ie: US |
| | | 72 | | private string? _sISO3166CountryName2; // 3 char ISO 3166 country name 2 2(RegionInfo) ex: USA (ISO) |
| | 0 | 73 | | private int _iGeoId = undef; // GeoId |
| | | 74 | | |
| | | 75 | | // Numbers |
| | | 76 | | private string? _sPositiveSign; // (user can override) positive sign |
| | | 77 | | private string? _sNegativeSign; // (user can override) negative sign |
| | | 78 | | // (nfi populates these 5, don't have to be = undef) |
| | | 79 | | private int _iDigits; // (user can override) number of fractional digits |
| | | 80 | | private int _iNegativeNumber; // (user can override) negative number format |
| | | 81 | | private int[]? _waGrouping; // (user can override) grouping of digits |
| | | 82 | | private string? _sDecimalSeparator; // (user can override) decimal separator |
| | | 83 | | private string? _sThousandSeparator; // (user can override) thousands separator |
| | | 84 | | private string? _sNaN; // Not a Number |
| | | 85 | | private string? _sPositiveInfinity; // + Infinity |
| | | 86 | | private string? _sNegativeInfinity; // - Infinity |
| | | 87 | | |
| | | 88 | | // Percent |
| | 0 | 89 | | private int _iNegativePercent = undef; // Negative Percent (0-3) |
| | 0 | 90 | | private int _iPositivePercent = undef; // Positive Percent (0-11) |
| | | 91 | | private string? _sPercent; // Percent (%) symbol |
| | | 92 | | private string? _sPerMille; // PerMille symbol |
| | | 93 | | |
| | | 94 | | // Currency |
| | | 95 | | private string? _sCurrency; // (user can override) local monetary symbol |
| | | 96 | | private string? _sIntlMonetarySymbol; // international monetary symbol (RegionInfo) |
| | | 97 | | private string? _sEnglishCurrency; // English name for this currency |
| | | 98 | | private string? _sNativeCurrency; // Native name for this currency |
| | | 99 | | // (nfi populates these 4, don't have to be = undef) |
| | | 100 | | private int _iCurrencyDigits; // (user can override) # local monetary fractional digits |
| | | 101 | | private int _iCurrency; // (user can override) positive currency format |
| | | 102 | | private int _iNegativeCurrency; // (user can override) negative currency format |
| | | 103 | | private int[]? _waMonetaryGrouping; // (user can override) monetary grouping of digits |
| | | 104 | | private string? _sMonetaryDecimal; // (user can override) monetary decimal separator |
| | | 105 | | private string? _sMonetaryThousand; // (user can override) monetary thousands separator |
| | | 106 | | |
| | | 107 | | // Misc |
| | 0 | 108 | | private int _iMeasure = undef; // (user can override) system of measurement 0=metric, 1=US (RegionInfo) |
| | | 109 | | private string? _sListSeparator; // (user can override) list separator |
| | | 110 | | |
| | | 111 | | // Time |
| | | 112 | | private string? _sAM1159; // (user can override) AM designator |
| | | 113 | | private string? _sPM2359; // (user can override) PM designator |
| | | 114 | | private string? _sTimeSeparator; |
| | | 115 | | private string[]? _saLongTimes; // (user can override) time format |
| | | 116 | | private string[]? _saShortTimes; // (user can override) short time format |
| | | 117 | | |
| | | 118 | | // Calendar specific data |
| | 0 | 119 | | private int _iFirstDayOfWeek = undef; // (user can override) first day of week (gregorian really) |
| | 0 | 120 | | private int _iFirstWeekOfYear = undef; // (user can override) first week of year (gregorian really) |
| | | 121 | | private CalendarId[]? _waCalendars; // all available calendar type(s). The first one is the default calendar |
| | | 122 | | |
| | | 123 | | // Store for specific data about each calendar |
| | | 124 | | private CalendarData?[]? _calendars; // Store for specific calendar data |
| | | 125 | | |
| | | 126 | | // Text information |
| | 0 | 127 | | private int _iReadingLayout = undef; // Reading layout data |
| | | 128 | | // 0 - Left to right (eg en-US) |
| | | 129 | | // 1 - Right to left (eg arabic locales) |
| | | 130 | | // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) |
| | | 131 | | // 3 - Vertical top to bottom with columns proceeding to the right |
| | | 132 | | |
| | | 133 | | // CoreCLR depends on this even though its not exposed publicly. |
| | | 134 | | |
| | 0 | 135 | | private int _iDefaultAnsiCodePage = undef; // default ansi code page ID (ACP) |
| | 0 | 136 | | private int _iDefaultOemCodePage = undef; // default oem code page ID (OCP or OEM) |
| | 0 | 137 | | private int _iDefaultMacCodePage = undef; // default macintosh code page |
| | 0 | 138 | | private int _iDefaultEbcdicCodePage = undef; // default EBCDIC code page |
| | | 139 | | |
| | | 140 | | private int _iLanguage; // locale ID (0409) - NO sort information |
| | | 141 | | private bool _bUseOverrides; // use user overrides? this depends on user setting and if is user default locale. |
| | | 142 | | private bool _bUseOverridesUserSetting; // the setting the user requested for. |
| | | 143 | | private bool _bNeutral; // Flags for the culture (ie: neutral or not right now) |
| | | 144 | | |
| | | 145 | | /// <summary> |
| | | 146 | | /// Region Name to Culture Name mapping table |
| | | 147 | | /// </summary> |
| | | 148 | | /// <remarks> |
| | | 149 | | /// Using a property so we avoid creating the dictionary until we need it |
| | | 150 | | /// </remarks> |
| | | 151 | | private static Dictionary<string, string> RegionNames => |
| | 0 | 152 | | s_regionNames ??= |
| | 0 | 153 | | new Dictionary<string, string>(255, StringComparer.OrdinalIgnoreCase) |
| | 0 | 154 | | { |
| | 0 | 155 | | { "001", "en-001" }, |
| | 0 | 156 | | { "029", "en-029" }, |
| | 0 | 157 | | { "150", "en-150" }, |
| | 0 | 158 | | { "419", "es-419" }, |
| | 0 | 159 | | { "AD", "ca-AD" }, |
| | 0 | 160 | | { "AE", "ar-AE" }, |
| | 0 | 161 | | { "AF", "prs-AF" }, |
| | 0 | 162 | | { "AG", "en-AG" }, |
| | 0 | 163 | | { "AI", "en-AI" }, |
| | 0 | 164 | | { "AL", "sq-AL" }, |
| | 0 | 165 | | { "AM", "hy-AM" }, |
| | 0 | 166 | | { "AO", "pt-AO" }, |
| | 0 | 167 | | { "AQ", "en-AQ" }, |
| | 0 | 168 | | { "AR", "es-AR" }, |
| | 0 | 169 | | { "AS", "en-AS" }, |
| | 0 | 170 | | { "AT", "de-AT" }, |
| | 0 | 171 | | { "AU", "en-AU" }, |
| | 0 | 172 | | { "AW", "nl-AW" }, |
| | 0 | 173 | | { "AX", "sv-AX" }, |
| | 0 | 174 | | { "AZ", "az-Cyrl-AZ" }, |
| | 0 | 175 | | { "BA", "bs-Latn-BA" }, |
| | 0 | 176 | | { "BB", "en-BB" }, |
| | 0 | 177 | | { "BD", "bn-BD" }, |
| | 0 | 178 | | { "BE", "nl-BE" }, |
| | 0 | 179 | | { "BF", "fr-BF" }, |
| | 0 | 180 | | { "BG", "bg-BG" }, |
| | 0 | 181 | | { "BH", "ar-BH" }, |
| | 0 | 182 | | { "BI", "rn-BI" }, |
| | 0 | 183 | | { "BJ", "fr-BJ" }, |
| | 0 | 184 | | { "BL", "fr-BL" }, |
| | 0 | 185 | | { "BM", "en-BM" }, |
| | 0 | 186 | | { "BN", "ms-BN" }, |
| | 0 | 187 | | { "BO", "es-BO" }, |
| | 0 | 188 | | { "BQ", "nl-BQ" }, |
| | 0 | 189 | | { "BR", "pt-BR" }, |
| | 0 | 190 | | { "BS", "en-BS" }, |
| | 0 | 191 | | { "BT", "dz-BT" }, |
| | 0 | 192 | | { "BV", "nb-BV" }, |
| | 0 | 193 | | { "BW", "en-BW" }, |
| | 0 | 194 | | { "BY", "be-BY" }, |
| | 0 | 195 | | { "BZ", "en-BZ" }, |
| | 0 | 196 | | { "CA", "en-CA" }, |
| | 0 | 197 | | { "CC", "en-CC" }, |
| | 0 | 198 | | { "CD", "fr-CD" }, |
| | 0 | 199 | | { "CF", "sg-CF" }, |
| | 0 | 200 | | { "CG", "fr-CG" }, |
| | 0 | 201 | | { "CH", "it-CH" }, |
| | 0 | 202 | | { "CI", "fr-CI" }, |
| | 0 | 203 | | { "CK", "en-CK" }, |
| | 0 | 204 | | { "CL", "es-CL" }, |
| | 0 | 205 | | { "CM", "fr-CM" }, |
| | 0 | 206 | | { "CN", "zh-CN" }, |
| | 0 | 207 | | { "CO", "es-CO" }, |
| | 0 | 208 | | { "CR", "es-CR" }, |
| | 0 | 209 | | { "CS", "sr-Cyrl-CS" }, |
| | 0 | 210 | | { "CU", "es-CU" }, |
| | 0 | 211 | | { "CV", "pt-CV" }, |
| | 0 | 212 | | { "CW", "nl-CW" }, |
| | 0 | 213 | | { "CX", "en-CX" }, |
| | 0 | 214 | | { "CY", "el-CY" }, |
| | 0 | 215 | | { "CZ", "cs-CZ" }, |
| | 0 | 216 | | { "DE", "de-DE" }, |
| | 0 | 217 | | { "DJ", "fr-DJ" }, |
| | 0 | 218 | | { "DK", "da-DK" }, |
| | 0 | 219 | | { "DM", "en-DM" }, |
| | 0 | 220 | | { "DO", "es-DO" }, |
| | 0 | 221 | | { "DZ", "ar-DZ" }, |
| | 0 | 222 | | { "EC", "es-EC" }, |
| | 0 | 223 | | { "EE", "et-EE" }, |
| | 0 | 224 | | { "EG", "ar-EG" }, |
| | 0 | 225 | | { "ER", "tig-ER" }, |
| | 0 | 226 | | { "ES", "es-ES" }, |
| | 0 | 227 | | { "ET", "am-ET" }, |
| | 0 | 228 | | { "FI", "fi-FI" }, |
| | 0 | 229 | | { "FJ", "en-FJ" }, |
| | 0 | 230 | | { "FK", "en-FK" }, |
| | 0 | 231 | | { "FM", "en-FM" }, |
| | 0 | 232 | | { "FO", "fo-FO" }, |
| | 0 | 233 | | { "FR", "fr-FR" }, |
| | 0 | 234 | | { "GA", "fr-GA" }, |
| | 0 | 235 | | { "GB", "en-GB" }, |
| | 0 | 236 | | { "GD", "en-GD" }, |
| | 0 | 237 | | { "GE", "ka-GE" }, |
| | 0 | 238 | | { "GF", "fr-GF" }, |
| | 0 | 239 | | { "GG", "en-GG" }, |
| | 0 | 240 | | { "GH", "en-GH" }, |
| | 0 | 241 | | { "GI", "en-GI" }, |
| | 0 | 242 | | { "GL", "kl-GL" }, |
| | 0 | 243 | | { "GM", "en-GM" }, |
| | 0 | 244 | | { "GN", "fr-GN" }, |
| | 0 | 245 | | { "GP", "fr-GP" }, |
| | 0 | 246 | | { "GQ", "es-GQ" }, |
| | 0 | 247 | | { "GR", "el-GR" }, |
| | 0 | 248 | | { "GS", "en-GS" }, |
| | 0 | 249 | | { "GT", "es-GT" }, |
| | 0 | 250 | | { "GU", "en-GU" }, |
| | 0 | 251 | | { "GW", "pt-GW" }, |
| | 0 | 252 | | { "GY", "en-GY" }, |
| | 0 | 253 | | { "HK", "zh-HK" }, |
| | 0 | 254 | | { "HM", "en-HM" }, |
| | 0 | 255 | | { "HN", "es-HN" }, |
| | 0 | 256 | | { "HR", "hr-HR" }, |
| | 0 | 257 | | { "HT", "fr-HT" }, |
| | 0 | 258 | | { "HU", "hu-HU" }, |
| | 0 | 259 | | { "ID", "id-ID" }, |
| | 0 | 260 | | { "IE", "en-IE" }, |
| | 0 | 261 | | { "IL", "he-IL" }, |
| | 0 | 262 | | { "IM", "gv-IM" }, |
| | 0 | 263 | | { "IN", "hi-IN" }, |
| | 0 | 264 | | { "IO", "en-IO" }, |
| | 0 | 265 | | { "IQ", "ar-IQ" }, |
| | 0 | 266 | | { "IR", "fa-IR" }, |
| | 0 | 267 | | { "IS", "is-IS" }, |
| | 0 | 268 | | { "IT", "it-IT" }, |
| | 0 | 269 | | { "IV", "" }, |
| | 0 | 270 | | { "JE", "en-JE" }, |
| | 0 | 271 | | { "JM", "en-JM" }, |
| | 0 | 272 | | { "JO", "ar-JO" }, |
| | 0 | 273 | | { "JP", "ja-JP" }, |
| | 0 | 274 | | { "KE", "sw-KE" }, |
| | 0 | 275 | | { "KG", "ky-KG" }, |
| | 0 | 276 | | { "KH", "km-KH" }, |
| | 0 | 277 | | { "KI", "en-KI" }, |
| | 0 | 278 | | { "KM", "ar-KM" }, |
| | 0 | 279 | | { "KN", "en-KN" }, |
| | 0 | 280 | | { "KP", "ko-KP" }, |
| | 0 | 281 | | { "KR", "ko-KR" }, |
| | 0 | 282 | | { "KW", "ar-KW" }, |
| | 0 | 283 | | { "KY", "en-KY" }, |
| | 0 | 284 | | { "KZ", "kk-KZ" }, |
| | 0 | 285 | | { "LA", "lo-LA" }, |
| | 0 | 286 | | { "LB", "ar-LB" }, |
| | 0 | 287 | | { "LC", "en-LC" }, |
| | 0 | 288 | | { "LI", "de-LI" }, |
| | 0 | 289 | | { "LK", "si-LK" }, |
| | 0 | 290 | | { "LR", "en-LR" }, |
| | 0 | 291 | | { "LS", "st-LS" }, |
| | 0 | 292 | | { "LT", "lt-LT" }, |
| | 0 | 293 | | { "LU", "lb-LU" }, |
| | 0 | 294 | | { "LV", "lv-LV" }, |
| | 0 | 295 | | { "LY", "ar-LY" }, |
| | 0 | 296 | | { "MA", "ar-MA" }, |
| | 0 | 297 | | { "MC", "fr-MC" }, |
| | 0 | 298 | | { "MD", "ro-MD" }, |
| | 0 | 299 | | { "ME", "sr-Latn-ME" }, |
| | 0 | 300 | | { "MF", "fr-MF" }, |
| | 0 | 301 | | { "MG", "mg-MG" }, |
| | 0 | 302 | | { "MH", "en-MH" }, |
| | 0 | 303 | | { "MK", "mk-MK" }, |
| | 0 | 304 | | { "ML", "fr-ML" }, |
| | 0 | 305 | | { "MM", "my-MM" }, |
| | 0 | 306 | | { "MN", "mn-MN" }, |
| | 0 | 307 | | { "MO", "zh-MO" }, |
| | 0 | 308 | | { "MP", "en-MP" }, |
| | 0 | 309 | | { "MQ", "fr-MQ" }, |
| | 0 | 310 | | { "MR", "ar-MR" }, |
| | 0 | 311 | | { "MS", "en-MS" }, |
| | 0 | 312 | | { "MT", "mt-MT" }, |
| | 0 | 313 | | { "MU", "en-MU" }, |
| | 0 | 314 | | { "MV", "dv-MV" }, |
| | 0 | 315 | | { "MW", "en-MW" }, |
| | 0 | 316 | | { "MX", "es-MX" }, |
| | 0 | 317 | | { "MY", "ms-MY" }, |
| | 0 | 318 | | { "MZ", "pt-MZ" }, |
| | 0 | 319 | | { "NA", "en-NA" }, |
| | 0 | 320 | | { "NC", "fr-NC" }, |
| | 0 | 321 | | { "NE", "fr-NE" }, |
| | 0 | 322 | | { "NF", "en-NF" }, |
| | 0 | 323 | | { "NG", "ig-NG" }, |
| | 0 | 324 | | { "NI", "es-NI" }, |
| | 0 | 325 | | { "NL", "nl-NL" }, |
| | 0 | 326 | | { "NO", "nn-NO" }, |
| | 0 | 327 | | { "NP", "ne-NP" }, |
| | 0 | 328 | | { "NR", "en-NR" }, |
| | 0 | 329 | | { "NU", "en-NU" }, |
| | 0 | 330 | | { "NZ", "en-NZ" }, |
| | 0 | 331 | | { "OM", "ar-OM" }, |
| | 0 | 332 | | { "PA", "es-PA" }, |
| | 0 | 333 | | { "PE", "es-PE" }, |
| | 0 | 334 | | { "PF", "fr-PF" }, |
| | 0 | 335 | | { "PG", "en-PG" }, |
| | 0 | 336 | | { "PH", "en-PH" }, |
| | 0 | 337 | | { "PK", "ur-PK" }, |
| | 0 | 338 | | { "PL", "pl-PL" }, |
| | 0 | 339 | | { "PM", "fr-PM" }, |
| | 0 | 340 | | { "PN", "en-PN" }, |
| | 0 | 341 | | { "PR", "es-PR" }, |
| | 0 | 342 | | { "PS", "ar-PS" }, |
| | 0 | 343 | | { "PT", "pt-PT" }, |
| | 0 | 344 | | { "PW", "en-PW" }, |
| | 0 | 345 | | { "PY", "es-PY" }, |
| | 0 | 346 | | { "QA", "ar-QA" }, |
| | 0 | 347 | | { "RE", "fr-RE" }, |
| | 0 | 348 | | { "RO", "ro-RO" }, |
| | 0 | 349 | | { "RS", "sr-Latn-RS" }, |
| | 0 | 350 | | { "RU", "ru-RU" }, |
| | 0 | 351 | | { "RW", "rw-RW" }, |
| | 0 | 352 | | { "SA", "ar-SA" }, |
| | 0 | 353 | | { "SB", "en-SB" }, |
| | 0 | 354 | | { "SC", "fr-SC" }, |
| | 0 | 355 | | { "SD", "ar-SD" }, |
| | 0 | 356 | | { "SE", "sv-SE" }, |
| | 0 | 357 | | { "SG", "zh-SG" }, |
| | 0 | 358 | | { "SH", "en-SH" }, |
| | 0 | 359 | | { "SI", "sl-SI" }, |
| | 0 | 360 | | { "SJ", "nb-SJ" }, |
| | 0 | 361 | | { "SK", "sk-SK" }, |
| | 0 | 362 | | { "SL", "en-SL" }, |
| | 0 | 363 | | { "SM", "it-SM" }, |
| | 0 | 364 | | { "SN", "wo-SN" }, |
| | 0 | 365 | | { "SO", "so-SO" }, |
| | 0 | 366 | | { "SR", "nl-SR" }, |
| | 0 | 367 | | { "SS", "en-SS" }, |
| | 0 | 368 | | { "ST", "pt-ST" }, |
| | 0 | 369 | | { "SV", "es-SV" }, |
| | 0 | 370 | | { "SX", "nl-SX" }, |
| | 0 | 371 | | { "SY", "ar-SY" }, |
| | 0 | 372 | | { "SZ", "ss-SZ" }, |
| | 0 | 373 | | { "TC", "en-TC" }, |
| | 0 | 374 | | { "TD", "fr-TD" }, |
| | 0 | 375 | | { "TF", "fr-TF" }, |
| | 0 | 376 | | { "TG", "fr-TG" }, |
| | 0 | 377 | | { "TH", "th-TH" }, |
| | 0 | 378 | | { "TJ", "tg-Cyrl-TJ" }, |
| | 0 | 379 | | { "TK", "en-TK" }, |
| | 0 | 380 | | { "TL", "pt-TL" }, |
| | 0 | 381 | | { "TM", "tk-TM" }, |
| | 0 | 382 | | { "TN", "ar-TN" }, |
| | 0 | 383 | | { "TO", "to-TO" }, |
| | 0 | 384 | | { "TR", "tr-TR" }, |
| | 0 | 385 | | { "TT", "en-TT" }, |
| | 0 | 386 | | { "TV", "en-TV" }, |
| | 0 | 387 | | { "TW", "zh-TW" }, |
| | 0 | 388 | | { "TZ", "sw-TZ" }, |
| | 0 | 389 | | { "UA", "uk-UA" }, |
| | 0 | 390 | | { "UG", "sw-UG" }, |
| | 0 | 391 | | { "UM", "en-UM" }, |
| | 0 | 392 | | { "US", "en-US" }, |
| | 0 | 393 | | { "UY", "es-UY" }, |
| | 0 | 394 | | { "UZ", "uz-Cyrl-UZ" }, |
| | 0 | 395 | | { "VA", "it-VA" }, |
| | 0 | 396 | | { "VC", "en-VC" }, |
| | 0 | 397 | | { "VE", "es-VE" }, |
| | 0 | 398 | | { "VG", "en-VG" }, |
| | 0 | 399 | | { "VI", "en-VI" }, |
| | 0 | 400 | | { "VN", "vi-VN" }, |
| | 0 | 401 | | { "VU", "fr-VU" }, |
| | 0 | 402 | | { "WF", "fr-WF" }, |
| | 0 | 403 | | { "WS", "en-WS" }, |
| | 0 | 404 | | { "XK", "sq-XK" }, |
| | 0 | 405 | | { "YE", "ar-YE" }, |
| | 0 | 406 | | { "YT", "fr-YT" }, |
| | 0 | 407 | | { "ZA", "af-ZA" }, |
| | 0 | 408 | | { "ZM", "en-ZM" }, |
| | 0 | 409 | | { "ZW", "en-ZW" } |
| | 0 | 410 | | }; |
| | | 411 | | |
| | | 412 | | // Cache of regions we've already looked up |
| | | 413 | | private static Dictionary<string, CultureData>? s_cachedRegions; |
| | | 414 | | private static Dictionary<string, string>? s_regionNames; |
| | | 415 | | |
| | | 416 | | /// <summary> |
| | | 417 | | /// The culture name to use to interop with the underlying native globalization libraries like ICU or Windows NL |
| | | 418 | | /// For example, we can have the name de_DE@collation=phonebook when using ICU for the German culture de-DE with |
| | | 419 | | /// </summary> |
| | 0 | 420 | | internal string? InteropName => _sWindowsName; |
| | | 421 | | |
| | | 422 | | internal static CultureData? GetCultureDataForRegion(string? cultureName, bool useUserOverride) |
| | | 423 | | { |
| | | 424 | | // First do a shortcut for Invariant |
| | 0 | 425 | | if (string.IsNullOrEmpty(cultureName)) |
| | | 426 | | { |
| | 0 | 427 | | return Invariant; |
| | | 428 | | } |
| | | 429 | | |
| | | 430 | | // First check if GetCultureData() can find it (ie: its a real culture) |
| | 0 | 431 | | CultureData? retVal = GetCultureData(cultureName, useUserOverride); |
| | 0 | 432 | | if (retVal != null && !retVal.IsNeutralCulture) |
| | | 433 | | { |
| | 0 | 434 | | return retVal; |
| | | 435 | | } |
| | | 436 | | |
| | | 437 | | // If it was neutral remember that so that RegionInfo() can throw the right exception |
| | 0 | 438 | | CultureData? neutral = retVal; |
| | | 439 | | |
| | | 440 | | // Try the hash table next |
| | 0 | 441 | | string hashName = AnsiToLower(useUserOverride ? cultureName : cultureName + '*'); |
| | 0 | 442 | | Dictionary<string, CultureData>? tempHashTable = s_cachedRegions; |
| | | 443 | | |
| | 0 | 444 | | if (tempHashTable == null) |
| | | 445 | | { |
| | | 446 | | // No table yet, make a new one |
| | 0 | 447 | | var newTable = new Dictionary<string, CultureData>(); |
| | 0 | 448 | | tempHashTable = Interlocked.CompareExchange(ref s_cachedRegions, newTable, null) ?? newTable; |
| | | 449 | | } |
| | | 450 | | else |
| | | 451 | | { |
| | | 452 | | // Check the hash table |
| | 0 | 453 | | lock (tempHashTable) |
| | | 454 | | { |
| | 0 | 455 | | tempHashTable.TryGetValue(hashName, out retVal); |
| | 0 | 456 | | } |
| | 0 | 457 | | if (retVal != null) |
| | | 458 | | { |
| | 0 | 459 | | return retVal; |
| | | 460 | | } |
| | | 461 | | } |
| | | 462 | | |
| | | 463 | | // Not found in the hash table, look it up the hard way |
| | | 464 | | |
| | | 465 | | // If not a valid mapping from the registry we'll have to try the hard coded table |
| | 0 | 466 | | if (retVal == null || retVal.IsNeutralCulture) |
| | | 467 | | { |
| | | 468 | | // Not a valid mapping, try the hard coded table |
| | 0 | 469 | | if (RegionNames.TryGetValue(cultureName, out string? name)) |
| | | 470 | | { |
| | | 471 | | // Make sure we can get culture data for it |
| | 0 | 472 | | retVal = GetCultureData(name, useUserOverride); |
| | | 473 | | } |
| | | 474 | | } |
| | | 475 | | |
| | | 476 | | // If not found in the hard coded table we'll have to find a culture that works for us |
| | 0 | 477 | | if (!GlobalizationMode.Invariant && (retVal == null || retVal.IsNeutralCulture)) |
| | | 478 | | { |
| | 0 | 479 | | retVal = GlobalizationMode.UseNls ? NlsGetCultureDataFromRegionName(cultureName) : IcuGetCultureDataFrom |
| | | 480 | | } |
| | | 481 | | |
| | | 482 | | // If we found one we can use, then cache it for next time |
| | 0 | 483 | | if (retVal != null && !retVal.IsNeutralCulture) |
| | | 484 | | { |
| | | 485 | | // first add it to the cache |
| | 0 | 486 | | lock (tempHashTable) |
| | | 487 | | { |
| | 0 | 488 | | tempHashTable[hashName] = retVal; |
| | 0 | 489 | | } |
| | | 490 | | } |
| | | 491 | | else |
| | | 492 | | { |
| | | 493 | | // Unable to find a matching culture/region, return null or neutral |
| | | 494 | | // (regionInfo throws a more specific exception on neutrals) |
| | 0 | 495 | | retVal = neutral; |
| | | 496 | | } |
| | | 497 | | |
| | | 498 | | // Return the found culture to use, null, or the neutral culture. |
| | 0 | 499 | | return retVal; |
| | | 500 | | } |
| | | 501 | | |
| | | 502 | | // Clear our internal caches |
| | | 503 | | internal static void ClearCachedData() |
| | | 504 | | { |
| | 0 | 505 | | s_cachedCultures = null; |
| | 0 | 506 | | s_cachedRegions = null; |
| | 0 | 507 | | } |
| | | 508 | | |
| | | 509 | | internal static CultureInfo[] GetCultures(CultureTypes types) |
| | | 510 | | { |
| | | 511 | | // Disable warning 618: System.Globalization.CultureTypes.FrameworkCultures' is obsolete |
| | | 512 | | #pragma warning disable 618 |
| | | 513 | | // Validate flags |
| | 0 | 514 | | if ((int)types <= 0 || ((int)types & (int)~(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures | |
| | 0 | 515 | | CultureTypes.InstalledWin32Cultures | CultureTypes.UserCustomCul |
| | 0 | 516 | | CultureTypes.ReplacementCultures | CultureTypes.WindowsOnlyCultu |
| | 0 | 517 | | CultureTypes.FrameworkCultures)) != 0) |
| | | 518 | | { |
| | 0 | 519 | | throw new ArgumentOutOfRangeException(nameof(types), |
| | 0 | 520 | | SR.Format(SR.ArgumentOutOfRange_Range, CultureTypes.NeutralCultures, CultureTypes.Framewor |
| | | 521 | | } |
| | | 522 | | |
| | | 523 | | // We have deprecated CultureTypes.FrameworkCultures. |
| | | 524 | | // When this enum is used, we will enumerate Whidbey framework cultures (for compatibility). |
| | | 525 | | |
| | | 526 | | // We have deprecated CultureTypes.WindowsOnlyCultures. |
| | | 527 | | // When this enum is used, we will return an empty array for this enum. |
| | 0 | 528 | | if ((types & CultureTypes.WindowsOnlyCultures) != 0) |
| | | 529 | | { |
| | | 530 | | // Remove the enum as it is an no-op. |
| | 0 | 531 | | types &= (~CultureTypes.WindowsOnlyCultures); |
| | | 532 | | } |
| | | 533 | | |
| | 0 | 534 | | if (GlobalizationMode.Invariant) |
| | | 535 | | { |
| | | 536 | | // in invariant mode we always return invariant culture only from the enumeration |
| | 0 | 537 | | return [new CultureInfo("")]; |
| | | 538 | | } |
| | | 539 | | |
| | | 540 | | #pragma warning restore 618 |
| | 0 | 541 | | return GlobalizationMode.UseNls ? NlsEnumCultures(types) : IcuEnumCultures(types); |
| | | 542 | | } |
| | | 543 | | |
| | | 544 | | private static CultureData CreateCultureWithInvariantData() |
| | | 545 | | { |
| | | 546 | | // Make a new culturedata |
| | 0 | 547 | | CultureData invariant = new CultureData(); |
| | | 548 | | |
| | | 549 | | // Basics |
| | | 550 | | // Note that we override the resources since this IS NOT supposed to change (by definition) |
| | 0 | 551 | | invariant._bUseOverrides = false; |
| | 0 | 552 | | invariant._bUseOverridesUserSetting = false; |
| | 0 | 553 | | invariant._sRealName = ""; // Name you passed in (ie: en-US, en, or de-DE_phoneb) |
| | 0 | 554 | | invariant._sWindowsName = ""; // Name OS thinks the object is (ie: de-DE_phoneb, or en-U |
| | | 555 | | |
| | | 556 | | // Identity |
| | 0 | 557 | | invariant._sName = ""; // locale name (ie: en-us) |
| | 0 | 558 | | invariant._sParent = ""; // Parent name (which may be a custom locale/culture) |
| | 0 | 559 | | invariant._bNeutral = false; // Flags for the culture (ie: neutral or not right now) |
| | 0 | 560 | | invariant._sEnglishDisplayName = "Invariant Language (Invariant Country)"; // English pretty name for this l |
| | 0 | 561 | | invariant._sNativeDisplayName = "Invariant Language (Invariant Country)"; // Native pretty name for this lo |
| | 0 | 562 | | invariant._sSpecificCulture = ""; // The culture name to be used in CultureInfo.CreateSp |
| | | 563 | | |
| | | 564 | | // Language |
| | 0 | 565 | | invariant._sISO639Language = "iv"; // ISO 639 Language Name |
| | 0 | 566 | | invariant._sISO639Language2 = "ivl"; // 3 char ISO 639 lang name 2 |
| | 0 | 567 | | invariant._sEnglishLanguage = "Invariant Language"; // English name for this language |
| | 0 | 568 | | invariant._sNativeLanguage = "Invariant Language"; // Native name of this language |
| | 0 | 569 | | invariant._sAbbrevLang = "IVL"; // abbreviated language name (Windows Language Name) |
| | 0 | 570 | | invariant._sConsoleFallbackName = ""; // The culture name for the console fallback UI culture |
| | 0 | 571 | | invariant._iInputLanguageHandle = 0x07F; // input language handle |
| | | 572 | | |
| | | 573 | | // Region |
| | 0 | 574 | | invariant._sRegionName = "IV"; // (RegionInfo) |
| | 0 | 575 | | invariant._sEnglishCountry = "Invariant Country"; // english country name (RegionInfo) |
| | 0 | 576 | | invariant._sNativeCountry = "Invariant Country"; // native country name (Windows Only) |
| | 0 | 577 | | invariant._sISO3166CountryName = "IV"; // (RegionInfo), ie: US |
| | 0 | 578 | | invariant._sISO3166CountryName2 = "ivc"; // 3 char ISO 3166 country name 2 2(RegionInfo) |
| | 0 | 579 | | invariant._iGeoId = 244; // GeoId (Windows Only) |
| | | 580 | | |
| | | 581 | | // Numbers |
| | 0 | 582 | | invariant._sPositiveSign = "+"; // positive sign |
| | 0 | 583 | | invariant._sNegativeSign = "-"; // negative sign |
| | 0 | 584 | | invariant._iDigits = 2; // number of fractional digits |
| | 0 | 585 | | invariant._iNegativeNumber = 1; // negative number format |
| | 0 | 586 | | invariant._waGrouping = [3]; // grouping of digits |
| | 0 | 587 | | invariant._sDecimalSeparator = "."; // decimal separator |
| | 0 | 588 | | invariant._sThousandSeparator = ","; // thousands separator |
| | 0 | 589 | | invariant._sNaN = "NaN"; // Not a Number |
| | 0 | 590 | | invariant._sPositiveInfinity = "Infinity"; // + Infinity |
| | 0 | 591 | | invariant._sNegativeInfinity = "-Infinity"; // - Infinity |
| | | 592 | | |
| | | 593 | | // Percent |
| | 0 | 594 | | invariant._iNegativePercent = 0; // Negative Percent (0-3) |
| | 0 | 595 | | invariant._iPositivePercent = 0; // Positive Percent (0-11) |
| | 0 | 596 | | invariant._sPercent = "%"; // Percent (%) symbol |
| | 0 | 597 | | invariant._sPerMille = "\x2030"; // PerMille symbol |
| | | 598 | | |
| | | 599 | | // Currency |
| | 0 | 600 | | invariant._sCurrency = "\x00a4"; // local monetary symbol: for international monetary symbol |
| | 0 | 601 | | invariant._sIntlMonetarySymbol = "XDR"; // international monetary symbol (RegionInfo) |
| | 0 | 602 | | invariant._sEnglishCurrency = "International Monetary Fund"; // English name for this currency (Windows Only |
| | 0 | 603 | | invariant._sNativeCurrency = "International Monetary Fund"; // Native name for this currency (Windows Only) |
| | 0 | 604 | | invariant._iCurrencyDigits = 2; // # local monetary fractional digits |
| | 0 | 605 | | invariant._iCurrency = 0; // positive currency format |
| | 0 | 606 | | invariant._iNegativeCurrency = 0; // negative currency format |
| | 0 | 607 | | invariant._waMonetaryGrouping = [3]; // monetary grouping of digits |
| | 0 | 608 | | invariant._sMonetaryDecimal = "."; // monetary decimal separator |
| | 0 | 609 | | invariant._sMonetaryThousand = ","; // monetary thousands separator |
| | | 610 | | |
| | | 611 | | // Misc |
| | 0 | 612 | | invariant._iMeasure = 0; // system of measurement 0=metric, 1=US (RegionInfo) |
| | 0 | 613 | | invariant._sListSeparator = ","; // list separator |
| | | 614 | | |
| | | 615 | | // Time |
| | 0 | 616 | | invariant._sTimeSeparator = ":"; |
| | 0 | 617 | | invariant._sAM1159 = "AM"; // AM designator |
| | 0 | 618 | | invariant._sPM2359 = "PM"; // PM designator |
| | 0 | 619 | | invariant._saLongTimes = ["HH:mm:ss"]; // time format |
| | 0 | 620 | | invariant._saShortTimes = ["HH:mm", "hh:mm tt", "H:mm", "h:mm tt"]; // short time format |
| | | 621 | | |
| | | 622 | | // Calendar specific data |
| | 0 | 623 | | invariant._iFirstDayOfWeek = 0; // first day of week |
| | 0 | 624 | | invariant._iFirstWeekOfYear = 0; // first week of year |
| | | 625 | | |
| | | 626 | | // Calendar information is expensive size-wise, especially for AOT. |
| | | 627 | | // CalendarData.Invariant is special cased in _waCalendars and _calendars |
| | | 628 | | // accessors and gets initialized lazily. |
| | | 629 | | // invariant._waCalendars |
| | | 630 | | // invariant._calendars |
| | | 631 | | |
| | | 632 | | // Text information |
| | 0 | 633 | | invariant._iReadingLayout = 0; |
| | | 634 | | |
| | | 635 | | // These are .NET Framework only, not coreclr |
| | | 636 | | |
| | 0 | 637 | | invariant._iLanguage = CultureInfo.LOCALE_INVARIANT; // locale ID (0409) - NO sort information |
| | 0 | 638 | | invariant._iDefaultAnsiCodePage = 1252; // default ansi code page ID (ACP) |
| | 0 | 639 | | invariant._iDefaultOemCodePage = 437; // default oem code page ID (OCP or OEM) |
| | 0 | 640 | | invariant._iDefaultMacCodePage = 10000; // default macintosh code page |
| | 0 | 641 | | invariant._iDefaultEbcdicCodePage = 037; // default EBCDIC code page |
| | | 642 | | |
| | | 643 | | // _sLocalizedCountry is intentionally left null here. It is populated lazily the first |
| | | 644 | | // time the LocalizedCountryName property is accessed. We avoid reading GlobalizationMode |
| | | 645 | | // here because doing so triggers ICU load in GlobalizationMode.Settings.cctor. During |
| | | 646 | | // runtime startup that load can fail and crash the process on some platforms such as Android. |
| | 0 | 647 | | return invariant; |
| | | 648 | | } |
| | | 649 | | |
| | | 650 | | /// <summary> |
| | | 651 | | /// Build our invariant information |
| | | 652 | | /// We need an invariant instance, which we build hard-coded |
| | | 653 | | /// </summary> |
| | 0 | 654 | | internal static CultureData Invariant => field ??= CreateCultureWithInvariantData(); |
| | | 655 | | |
| | | 656 | | // Cache of cultures we've already looked up |
| | | 657 | | private static Dictionary<string, CultureData>? s_cachedCultures; |
| | | 658 | | |
| | | 659 | | internal static CultureData? GetCultureData(string? cultureName, bool useUserOverride) |
| | | 660 | | { |
| | | 661 | | // The undetermined culture name "und" is not a real culture, but it resolves to the invariant culture becau |
| | | 662 | | const string UndeterminedCultureName = "und"; |
| | | 663 | | |
| | | 664 | | // First do a shortcut for Invariant |
| | 0 | 665 | | if (string.IsNullOrEmpty(cultureName) || cultureName.Equals(UndeterminedCultureName, StringComparison.Ordina |
| | | 666 | | { |
| | 0 | 667 | | return Invariant; |
| | | 668 | | } |
| | | 669 | | |
| | 0 | 670 | | if (GlobalizationMode.PredefinedCulturesOnly) |
| | | 671 | | { |
| | 0 | 672 | | if (GlobalizationMode.Invariant || (GlobalizationMode.UseNls ? !NlsIsEnsurePredefinedLocaleName(cultureN |
| | 0 | 673 | | return null; |
| | | 674 | | } |
| | | 675 | | |
| | | 676 | | // Try the hash table first |
| | 0 | 677 | | string hashName = AnsiToLower(useUserOverride ? cultureName : cultureName + '*'); |
| | 0 | 678 | | Dictionary<string, CultureData>? tempHashTable = s_cachedCultures; |
| | 0 | 679 | | if (tempHashTable == null) |
| | | 680 | | { |
| | | 681 | | // No table yet, make a new one |
| | 0 | 682 | | var newTable = new Dictionary<string, CultureData>(); |
| | 0 | 683 | | tempHashTable = Interlocked.CompareExchange(ref s_cachedCultures, newTable, null) ?? newTable; |
| | | 684 | | } |
| | | 685 | | else |
| | | 686 | | { |
| | | 687 | | // Check the hash table |
| | | 688 | | bool ret; |
| | | 689 | | CultureData? retVal; |
| | 0 | 690 | | lock (tempHashTable) |
| | | 691 | | { |
| | 0 | 692 | | ret = tempHashTable.TryGetValue(hashName, out retVal); |
| | 0 | 693 | | } |
| | 0 | 694 | | if (ret && retVal != null) |
| | | 695 | | { |
| | 0 | 696 | | return retVal; |
| | | 697 | | } |
| | | 698 | | } |
| | | 699 | | // Not found in the hash table, need to see if we can build one that works for us |
| | 0 | 700 | | CultureData? culture = CreateCultureData(cultureName, useUserOverride); |
| | 0 | 701 | | if (culture == null) |
| | | 702 | | { |
| | 0 | 703 | | return null; |
| | | 704 | | } |
| | | 705 | | |
| | | 706 | | // Found one, add it to the cache |
| | 0 | 707 | | lock (tempHashTable) |
| | | 708 | | { |
| | 0 | 709 | | tempHashTable[hashName] = culture; |
| | 0 | 710 | | } |
| | | 711 | | |
| | 0 | 712 | | return culture; |
| | | 713 | | } |
| | | 714 | | |
| | | 715 | | private static unsafe string NormalizeCultureName(string name, out bool isNeutralName) |
| | | 716 | | { |
| | 0 | 717 | | isNeutralName = true; |
| | 0 | 718 | | int i = 0; |
| | | 719 | | |
| | 0 | 720 | | if (name.Length > LocaleNameMaxLength) |
| | | 721 | | { |
| | | 722 | | // Theoretically we shouldn't hit this exception. |
| | 0 | 723 | | throw new ArgumentException(SR.Format(SR.Argument_InvalidId, nameof(name))); |
| | | 724 | | } |
| | | 725 | | |
| | 0 | 726 | | Span<char> normalizedName = stackalloc char[name.Length]; |
| | | 727 | | |
| | 0 | 728 | | bool changed = false; |
| | | 729 | | |
| | 0 | 730 | | while (i < name.Length && name[i] != '-' && name[i] != '_') |
| | | 731 | | { |
| | 0 | 732 | | if (char.IsAsciiLetterUpper(name[i])) |
| | | 733 | | { |
| | | 734 | | // lowercase characters before '-' |
| | 0 | 735 | | normalizedName[i] = (char)(((int)name[i]) + 0x20); |
| | 0 | 736 | | changed = true; |
| | | 737 | | } |
| | | 738 | | else |
| | | 739 | | { |
| | 0 | 740 | | normalizedName[i] = name[i]; |
| | | 741 | | } |
| | 0 | 742 | | i++; |
| | | 743 | | } |
| | | 744 | | |
| | 0 | 745 | | if (i < name.Length) |
| | | 746 | | { |
| | | 747 | | // this is not perfect to detect the non neutral cultures but it is good enough when we are running in i |
| | 0 | 748 | | isNeutralName = false; |
| | | 749 | | } |
| | | 750 | | |
| | 0 | 751 | | while (i < name.Length) |
| | | 752 | | { |
| | 0 | 753 | | if (char.IsAsciiLetterLower(name[i])) |
| | | 754 | | { |
| | 0 | 755 | | normalizedName[i] = (char)(((int)name[i]) - 0x20); |
| | 0 | 756 | | changed = true; |
| | | 757 | | } |
| | | 758 | | else |
| | | 759 | | { |
| | 0 | 760 | | normalizedName[i] = name[i]; |
| | | 761 | | } |
| | 0 | 762 | | i++; |
| | | 763 | | } |
| | | 764 | | |
| | 0 | 765 | | if (changed) |
| | | 766 | | { |
| | 0 | 767 | | return new string(normalizedName); |
| | | 768 | | } |
| | | 769 | | |
| | 0 | 770 | | return name; |
| | | 771 | | } |
| | | 772 | | |
| | | 773 | | private static CultureData? CreateCultureData(string cultureName, bool useUserOverride) |
| | | 774 | | { |
| | 0 | 775 | | if (GlobalizationMode.Invariant) |
| | | 776 | | { |
| | 0 | 777 | | if (cultureName.Length > LocaleNameMaxLength || !CultureInfo.VerifyCultureName(cultureName, false)) |
| | | 778 | | { |
| | 0 | 779 | | return null; |
| | | 780 | | } |
| | 0 | 781 | | CultureData cd = CreateCultureWithInvariantData(); |
| | 0 | 782 | | cd._sName = NormalizeCultureName(cultureName, out cd._bNeutral); |
| | 0 | 783 | | cd._bUseOverridesUserSetting = useUserOverride; |
| | 0 | 784 | | cd._sRealName = cd._sName; |
| | 0 | 785 | | cd._sWindowsName = cd._sName; |
| | 0 | 786 | | cd._iLanguage = CultureInfo.LOCALE_CUSTOM_UNSPECIFIED; |
| | | 787 | | |
| | 0 | 788 | | return cd; |
| | | 789 | | } |
| | | 790 | | |
| | 0 | 791 | | if (cultureName.Length == 1 && (cultureName[0] == 'C' || cultureName[0] == 'c')) |
| | | 792 | | { |
| | | 793 | | // Always map the "C" locale to Invariant to avoid mapping it to en_US_POSIX on Linux because POSIX |
| | | 794 | | // locale collation doesn't support case insensitive comparisons. |
| | | 795 | | // We do the same mapping on Windows for the sake of consistency. |
| | 0 | 796 | | return Invariant; |
| | | 797 | | } |
| | | 798 | | |
| | 0 | 799 | | CultureData culture = new CultureData(); |
| | 0 | 800 | | culture._sRealName = cultureName; |
| | 0 | 801 | | culture._bUseOverridesUserSetting = useUserOverride; |
| | | 802 | | |
| | | 803 | | // Ask native code if that one's real, populate _sWindowsName |
| | 0 | 804 | | if (!culture.InitCultureDataCore() && !culture.InitCompatibilityCultureData()) |
| | | 805 | | { |
| | 0 | 806 | | return null; |
| | | 807 | | } |
| | | 808 | | #if TARGET_BROWSER |
| | | 809 | | culture.JSInitLocaleInfo(); |
| | | 810 | | #endif |
| | | 811 | | |
| | | 812 | | // We need _sWindowsName to be initialized to know if we're using overrides. |
| | 0 | 813 | | culture.InitUserOverride(useUserOverride); |
| | 0 | 814 | | return culture; |
| | | 815 | | } |
| | | 816 | | |
| | | 817 | | private bool InitCompatibilityCultureData() |
| | | 818 | | { |
| | | 819 | | // for compatibility handle the deprecated ids: zh-chs, zh-cht |
| | 0 | 820 | | string cultureName = _sRealName; |
| | | 821 | | |
| | | 822 | | string fallbackCultureName; |
| | | 823 | | string realCultureName; |
| | 0 | 824 | | switch (AnsiToLower(cultureName)) |
| | | 825 | | { |
| | | 826 | | case "zh-chs": |
| | 0 | 827 | | fallbackCultureName = "zh-Hans"; |
| | 0 | 828 | | realCultureName = "zh-CHS"; |
| | 0 | 829 | | break; |
| | | 830 | | case "zh-cht": |
| | 0 | 831 | | fallbackCultureName = "zh-Hant"; |
| | 0 | 832 | | realCultureName = "zh-CHT"; |
| | 0 | 833 | | break; |
| | | 834 | | default: |
| | 0 | 835 | | return false; |
| | | 836 | | } |
| | | 837 | | |
| | 0 | 838 | | _sRealName = fallbackCultureName; |
| | 0 | 839 | | if (!InitCultureDataCore()) |
| | | 840 | | { |
| | 0 | 841 | | return false; |
| | | 842 | | } |
| | | 843 | | |
| | | 844 | | // fixup our data |
| | 0 | 845 | | _sName = realCultureName; // the name that goes back to the user |
| | 0 | 846 | | _sParent = fallbackCultureName; |
| | | 847 | | |
| | 0 | 848 | | return true; |
| | | 849 | | } |
| | | 850 | | |
| | | 851 | | /// We'd rather people use the named version since this doesn't allow custom locales |
| | | 852 | | internal static CultureData GetCultureData(int culture, bool bUseUserOverride) |
| | | 853 | | { |
| | 0 | 854 | | CultureData? retVal = null; |
| | | 855 | | |
| | 0 | 856 | | if (culture == CultureInfo.LOCALE_INVARIANT) |
| | | 857 | | { |
| | 0 | 858 | | return Invariant; |
| | | 859 | | } |
| | | 860 | | |
| | 0 | 861 | | if (GlobalizationMode.Invariant) |
| | | 862 | | { |
| | 0 | 863 | | if (!GlobalizationMode.PredefinedCulturesOnly) |
| | | 864 | | { |
| | 0 | 865 | | if (culture is < 1 or > 0xf_ffff) |
| | | 866 | | { |
| | 0 | 867 | | throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupported); |
| | | 868 | | } |
| | | 869 | | |
| | 0 | 870 | | return Invariant; |
| | | 871 | | } |
| | | 872 | | |
| | | 873 | | // LCID is not supported in the InvariantMode |
| | 0 | 874 | | throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupportedInInvariantM |
| | | 875 | | } |
| | | 876 | | |
| | | 877 | | // Convert the lcid to a name, then use that |
| | 0 | 878 | | string? localeName = LCIDToLocaleName(culture); |
| | | 879 | | |
| | 0 | 880 | | if (!string.IsNullOrEmpty(localeName)) |
| | | 881 | | { |
| | | 882 | | // Valid name, use it |
| | 0 | 883 | | retVal = GetCultureData(localeName, bUseUserOverride); |
| | | 884 | | } |
| | | 885 | | |
| | | 886 | | // If not successful, throw |
| | 0 | 887 | | if (retVal == null) |
| | | 888 | | { |
| | 0 | 889 | | throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupported); |
| | | 890 | | } |
| | | 891 | | |
| | | 892 | | // Return the one we found |
| | 0 | 893 | | return retVal; |
| | | 894 | | } |
| | | 895 | | |
| | | 896 | | /// <summary> |
| | | 897 | | /// The real name used to construct the locale (ie: de-DE_phoneb) |
| | | 898 | | /// </summary> |
| | | 899 | | internal string CultureName |
| | | 900 | | { |
| | | 901 | | get |
| | | 902 | | { |
| | 0 | 903 | | Debug.Assert(_sRealName != null, "[CultureData.CultureName] Expected _sRealName to be populated by alrea |
| | | 904 | | // since windows doesn't know about zh-CHS and zh-CHT, |
| | | 905 | | // we leave sRealName == zh-Hanx but we still need to |
| | | 906 | | // pretend that it was zh-CHX. |
| | 0 | 907 | | return _sName is "zh-CHS" or "zh-CHT" ? _sName : _sRealName; |
| | | 908 | | } |
| | | 909 | | } |
| | | 910 | | |
| | | 911 | | /// <summary> |
| | | 912 | | /// Did the user request to use overrides? |
| | | 913 | | /// </summary> |
| | 0 | 914 | | internal bool UseUserOverride => _bUseOverridesUserSetting; |
| | | 915 | | |
| | | 916 | | /// <summary> |
| | | 917 | | /// locale name (ie: de-DE, NO sort information) |
| | | 918 | | /// </summary> |
| | 0 | 919 | | internal string Name => _sName ?? string.Empty; |
| | | 920 | | |
| | | 921 | | // Parent name (which may be a custom locale/culture) |
| | | 922 | | // Ask using the real name, so that we get parents of neutrals |
| | 0 | 923 | | internal string ParentName => _sParent ??= GetLocaleInfoCore(_sRealName, LocaleStringData.ParentName); |
| | | 924 | | |
| | | 925 | | // Localized pretty name for this locale (ie: Inglis (estados Unitos)) |
| | | 926 | | internal string DisplayName |
| | | 927 | | { |
| | | 928 | | get |
| | | 929 | | { |
| | 0 | 930 | | string? localizedDisplayName = NativeName; |
| | 0 | 931 | | if (!GlobalizationMode.Invariant && Name.Length > 0) |
| | | 932 | | { |
| | | 933 | | try |
| | | 934 | | { |
| | 0 | 935 | | localizedDisplayName = GetLanguageDisplayNameCore( |
| | 0 | 936 | | Name.Equals("zh-CHT", StringComparison.OrdinalIgnoreCase) ? "zh-Hant" : |
| | 0 | 937 | | Name.Equals("zh-CHS", StringComparison.OrdinalIgnoreCase) ? "zh-Hans" : |
| | 0 | 938 | | Name); |
| | 0 | 939 | | } |
| | 0 | 940 | | catch |
| | | 941 | | { |
| | | 942 | | // do nothing |
| | 0 | 943 | | } |
| | | 944 | | |
| | | 945 | | // If it hasn't been found (Windows 8 and up), fallback to the system |
| | 0 | 946 | | if (string.IsNullOrEmpty(localizedDisplayName) && IsNeutralCulture) |
| | | 947 | | { |
| | 0 | 948 | | localizedDisplayName = LocalizedLanguageName; |
| | | 949 | | } |
| | | 950 | | } |
| | | 951 | | |
| | 0 | 952 | | return localizedDisplayName; |
| | | 953 | | } |
| | | 954 | | } |
| | | 955 | | |
| | 0 | 956 | | private string GetLanguageDisplayNameCore(string cultureName) => GlobalizationMode.UseNls ? |
| | 0 | 957 | | NlsGetLanguageDisplayName(cultureName) : |
| | 0 | 958 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | 0 | 959 | | GlobalizationMode.Hybrid ? |
| | 0 | 960 | | GetLocaleInfoNative(cultureName, LocaleStrin |
| | 0 | 961 | | #endif |
| | 0 | 962 | | IcuGetLanguageDisplayName(cultureName); |
| | | 963 | | |
| | | 964 | | /// <summary> |
| | | 965 | | /// English pretty name for this locale (ie: English (United States)) |
| | | 966 | | /// </summary> |
| | | 967 | | internal string EnglishName |
| | | 968 | | { |
| | | 969 | | get |
| | | 970 | | { |
| | 0 | 971 | | string? englishDisplayName = _sEnglishDisplayName; |
| | 0 | 972 | | if (englishDisplayName == null && !GlobalizationMode.Invariant) |
| | | 973 | | { |
| | | 974 | | // If its neutral use the language name |
| | 0 | 975 | | if (IsNeutralCulture) |
| | | 976 | | { |
| | 0 | 977 | | englishDisplayName = GetLocaleInfoCore(LocaleStringData.EnglishDisplayName); |
| | 0 | 978 | | if (string.IsNullOrEmpty(englishDisplayName)) |
| | | 979 | | { |
| | 0 | 980 | | englishDisplayName = EnglishLanguageName; |
| | | 981 | | } |
| | | 982 | | |
| | | 983 | | // differentiate the legacy display names |
| | 0 | 984 | | switch (_sName) |
| | | 985 | | { |
| | | 986 | | case "zh-CHS": |
| | | 987 | | case "zh-CHT": |
| | 0 | 988 | | englishDisplayName += " Legacy"; |
| | 0 | 989 | | break; |
| | | 990 | | } |
| | | 991 | | } |
| | | 992 | | else |
| | | 993 | | { |
| | 0 | 994 | | englishDisplayName = GetLocaleInfoCore(LocaleStringData.EnglishDisplayName); |
| | | 995 | | |
| | | 996 | | // if it isn't found build one: |
| | 0 | 997 | | if (string.IsNullOrEmpty(englishDisplayName)) |
| | | 998 | | { |
| | | 999 | | // Our existing names mostly look like: |
| | | 1000 | | // "English" + "United States" -> "English (United States)" |
| | | 1001 | | // "Azeri (Latin)" + "Azerbaijan" -> "Azeri (Latin, Azerbaijan)" |
| | 0 | 1002 | | if (EnglishLanguageName.EndsWith(')')) |
| | | 1003 | | { |
| | | 1004 | | // "Azeri (Latin)" + "Azerbaijan" -> "Azeri (Latin, Azerbaijan)" |
| | 0 | 1005 | | englishDisplayName = string.Concat( |
| | 0 | 1006 | | EnglishLanguageName.AsSpan(0, _sEnglishLanguage!.Length - 1), |
| | 0 | 1007 | | ", ", |
| | 0 | 1008 | | EnglishCountryName, |
| | 0 | 1009 | | ")"); |
| | | 1010 | | } |
| | | 1011 | | else |
| | | 1012 | | { |
| | | 1013 | | // "English" + "United States" -> "English (United States)" |
| | 0 | 1014 | | englishDisplayName = EnglishLanguageName + " (" + EnglishCountryName + ")"; |
| | | 1015 | | } |
| | | 1016 | | } |
| | | 1017 | | } |
| | | 1018 | | |
| | 0 | 1019 | | _sEnglishDisplayName = englishDisplayName; |
| | | 1020 | | } |
| | | 1021 | | |
| | 0 | 1022 | | return englishDisplayName!; |
| | | 1023 | | } |
| | | 1024 | | } |
| | | 1025 | | |
| | | 1026 | | /// <summary> |
| | | 1027 | | /// Native pretty name for this locale (ie: Deutsch (Deutschland)) |
| | | 1028 | | /// </summary> |
| | | 1029 | | internal string NativeName |
| | | 1030 | | { |
| | | 1031 | | get |
| | | 1032 | | { |
| | 0 | 1033 | | string? nativeDisplayName = _sNativeDisplayName; |
| | 0 | 1034 | | if (nativeDisplayName == null && !GlobalizationMode.Invariant) |
| | | 1035 | | { |
| | | 1036 | | // If its neutral use the language name |
| | 0 | 1037 | | if (IsNeutralCulture) |
| | | 1038 | | { |
| | 0 | 1039 | | nativeDisplayName = GetLocaleInfoCore(LocaleStringData.NativeDisplayName); |
| | 0 | 1040 | | if (string.IsNullOrEmpty(nativeDisplayName)) |
| | | 1041 | | { |
| | 0 | 1042 | | nativeDisplayName = NativeLanguageName; |
| | | 1043 | | } |
| | | 1044 | | |
| | | 1045 | | // differentiate the legacy display names |
| | 0 | 1046 | | switch (_sName) |
| | | 1047 | | { |
| | | 1048 | | case "zh-CHS": |
| | 0 | 1049 | | nativeDisplayName += " \u65E7\u7248"; |
| | 0 | 1050 | | break; |
| | | 1051 | | case "zh-CHT": |
| | 0 | 1052 | | nativeDisplayName += " \u820A\u7248"; |
| | 0 | 1053 | | break; |
| | | 1054 | | } |
| | | 1055 | | } |
| | | 1056 | | else |
| | | 1057 | | { |
| | 0 | 1058 | | nativeDisplayName = GetLocaleInfoCore(LocaleStringData.NativeDisplayName); |
| | | 1059 | | |
| | | 1060 | | // if it isn't found build one: |
| | 0 | 1061 | | if (string.IsNullOrEmpty(nativeDisplayName)) |
| | | 1062 | | { |
| | | 1063 | | // These should primarily be "Deutsch (Deutschland)" type names |
| | 0 | 1064 | | nativeDisplayName = NativeLanguageName + " (" + NativeCountryName + ")"; |
| | | 1065 | | } |
| | | 1066 | | } |
| | | 1067 | | |
| | 0 | 1068 | | _sNativeDisplayName = nativeDisplayName; |
| | | 1069 | | } |
| | | 1070 | | |
| | 0 | 1071 | | return nativeDisplayName!; |
| | | 1072 | | } |
| | | 1073 | | } |
| | | 1074 | | |
| | | 1075 | | /// <summary> |
| | | 1076 | | /// The culture name to be used in CultureInfo.CreateSpecificCulture() |
| | | 1077 | | /// </summary> |
| | | 1078 | | internal string SpecificCultureName |
| | | 1079 | | { |
| | | 1080 | | get |
| | | 1081 | | { |
| | | 1082 | | // This got populated during the culture initialization |
| | 0 | 1083 | | Debug.Assert(_sSpecificCulture != null, "[CultureData.SpecificCultureName] Expected this.sSpecificCultur |
| | 0 | 1084 | | return _sSpecificCulture; |
| | | 1085 | | } |
| | | 1086 | | } |
| | | 1087 | | |
| | | 1088 | | /// <summary> |
| | | 1089 | | /// iso 639 language name, ie: en |
| | | 1090 | | /// </summary> |
| | 0 | 1091 | | internal string TwoLetterISOLanguageName => _sISO639Language ??= GetLocaleInfoCore(LocaleStringData.Iso639Langua |
| | | 1092 | | |
| | | 1093 | | /// <summary> |
| | | 1094 | | /// iso 639 language name, ie: eng |
| | | 1095 | | /// </summary> |
| | 0 | 1096 | | internal string ThreeLetterISOLanguageName => _sISO639Language2 ??= GetLocaleInfoCore(LocaleStringData.Iso639Lan |
| | | 1097 | | |
| | | 1098 | | /// <summary> |
| | | 1099 | | /// abbreviated windows language name (ie: enu) (non-standard, avoid this) |
| | | 1100 | | /// </summary> |
| | 0 | 1101 | | internal string ThreeLetterWindowsLanguageName => _sAbbrevLang ??= GlobalizationMode.UseNls ? |
| | 0 | 1102 | | NlsGetThreeLetterWindowsLanguageName(_sRealN |
| | 0 | 1103 | | IcuGetThreeLetterWindowsLanguageName(_sRealN |
| | | 1104 | | |
| | | 1105 | | /// <summary> |
| | | 1106 | | /// Localized name for this language |
| | | 1107 | | /// </summary> |
| | | 1108 | | private string LocalizedLanguageName |
| | | 1109 | | { |
| | | 1110 | | get |
| | | 1111 | | { |
| | 0 | 1112 | | string localizedLanguage = NativeLanguageName; |
| | 0 | 1113 | | if (!GlobalizationMode.Invariant && Name.Length > 0) |
| | | 1114 | | { |
| | | 1115 | | // If ICU is enabled we call it anyway. If NLS, we call it only if the Windows UI language match the |
| | 0 | 1116 | | if (!GlobalizationMode.UseNls || CultureInfo.UserDefaultUICulture?.Name == CultureInfo.CurrentUICult |
| | | 1117 | | { |
| | 0 | 1118 | | localizedLanguage = GetLocaleInfoCore(LocaleStringData.LocalizedLanguageName, CultureInfo.Curren |
| | | 1119 | | } |
| | | 1120 | | } |
| | | 1121 | | |
| | 0 | 1122 | | return localizedLanguage; |
| | | 1123 | | } |
| | | 1124 | | } |
| | | 1125 | | |
| | | 1126 | | /// <summary> |
| | | 1127 | | /// English name for this language (Windows Only) ie: German |
| | | 1128 | | /// </summary> |
| | 0 | 1129 | | private string EnglishLanguageName => _sEnglishLanguage ??= GetLocaleInfoCore(LocaleStringData.EnglishLanguageNa |
| | | 1130 | | |
| | | 1131 | | /// <summary> |
| | | 1132 | | /// Native name of this language (Windows Only) ie: Deutsch |
| | | 1133 | | /// </summary> |
| | 0 | 1134 | | private string NativeLanguageName => _sNativeLanguage ??= GetLocaleInfoCore(LocaleStringData.NativeLanguageName) |
| | | 1135 | | |
| | | 1136 | | /// <summary> |
| | | 1137 | | /// region name (eg US) |
| | | 1138 | | /// </summary> |
| | 0 | 1139 | | internal string RegionName => _sRegionName ??= GetLocaleInfoCore(LocaleStringData.Iso3166CountryName); |
| | | 1140 | | |
| | | 1141 | | internal int GeoId |
| | | 1142 | | { |
| | | 1143 | | get |
| | | 1144 | | { |
| | 0 | 1145 | | if (_iGeoId == undef && !GlobalizationMode.Invariant) |
| | | 1146 | | { |
| | 0 | 1147 | | _iGeoId = GlobalizationMode.UseNls ? NlsGetLocaleInfo(LocaleNumberData.GeoId) : IcuGetGeoId(_sRealNa |
| | | 1148 | | } |
| | 0 | 1149 | | return _iGeoId; |
| | | 1150 | | } |
| | | 1151 | | } |
| | | 1152 | | |
| | | 1153 | | /// <summary> |
| | | 1154 | | /// localized name for the country |
| | | 1155 | | /// </summary> |
| | | 1156 | | internal string LocalizedCountryName |
| | | 1157 | | { |
| | | 1158 | | get |
| | | 1159 | | { |
| | 0 | 1160 | | string? localizedCountry = _sLocalizedCountry; |
| | 0 | 1161 | | if (localizedCountry == null) |
| | | 1162 | | { |
| | 0 | 1163 | | if (!GlobalizationMode.Invariant) |
| | | 1164 | | { |
| | | 1165 | | try |
| | | 1166 | | { |
| | 0 | 1167 | | localizedCountry = GlobalizationMode.UseNls ? NlsGetRegionDisplayName() : IcuGetRegionDispla |
| | 0 | 1168 | | } |
| | 0 | 1169 | | catch |
| | | 1170 | | { |
| | | 1171 | | // do nothing. we'll fallback |
| | 0 | 1172 | | } |
| | 0 | 1173 | | localizedCountry ??= NativeCountryName; |
| | | 1174 | | } |
| | | 1175 | | else |
| | | 1176 | | { |
| | 0 | 1177 | | localizedCountry = NativeCountryName; |
| | | 1178 | | } |
| | 0 | 1179 | | _sLocalizedCountry = localizedCountry; |
| | | 1180 | | } |
| | | 1181 | | |
| | 0 | 1182 | | return localizedCountry; |
| | | 1183 | | } |
| | | 1184 | | } |
| | | 1185 | | |
| | | 1186 | | /// <summary> |
| | | 1187 | | /// english country name (RegionInfo) ie: Germany |
| | | 1188 | | /// </summary> |
| | 0 | 1189 | | internal string EnglishCountryName => _sEnglishCountry ??= GetLocaleInfoCore(LocaleStringData.EnglishCountryName |
| | | 1190 | | |
| | | 1191 | | /// <summary> |
| | | 1192 | | /// native country name (RegionInfo) ie: Deutschland |
| | | 1193 | | /// </summary> |
| | 0 | 1194 | | internal string NativeCountryName => _sNativeCountry ??= GetLocaleInfoCore(LocaleStringData.NativeCountryName); |
| | | 1195 | | |
| | | 1196 | | /// <summary> |
| | | 1197 | | /// ISO 3166 Country Name |
| | | 1198 | | /// </summary> |
| | 0 | 1199 | | internal string TwoLetterISOCountryName => _sISO3166CountryName ??= GetLocaleInfoCore(LocaleStringData.Iso3166Co |
| | | 1200 | | |
| | | 1201 | | /// <summary> |
| | | 1202 | | /// 3 letter ISO 3166 country code |
| | | 1203 | | /// </summary> |
| | 0 | 1204 | | internal string ThreeLetterISOCountryName => _sISO3166CountryName2 ??= GetLocaleInfoCore(LocaleStringData.Iso316 |
| | | 1205 | | |
| | | 1206 | | internal int KeyboardLayoutId |
| | | 1207 | | { |
| | | 1208 | | get |
| | | 1209 | | { |
| | 0 | 1210 | | if (_iInputLanguageHandle == undef) |
| | | 1211 | | { |
| | 0 | 1212 | | if (IsSupplementalCustomCulture) |
| | | 1213 | | { |
| | 0 | 1214 | | _iInputLanguageHandle = 0x0409; |
| | | 1215 | | } |
| | | 1216 | | else |
| | | 1217 | | { |
| | | 1218 | | // Input Language is same as LCID for built-in cultures |
| | 0 | 1219 | | _iInputLanguageHandle = LCID; |
| | | 1220 | | } |
| | | 1221 | | } |
| | 0 | 1222 | | return _iInputLanguageHandle; |
| | | 1223 | | } |
| | | 1224 | | } |
| | | 1225 | | |
| | | 1226 | | /// <summary> |
| | | 1227 | | /// Console fallback name (ie: locale to use for console apps for unicode-only locales) |
| | | 1228 | | /// </summary> |
| | 0 | 1229 | | internal string SCONSOLEFALLBACKNAME => _sConsoleFallbackName ??= GlobalizationMode.UseNls ? |
| | 0 | 1230 | | NlsGetConsoleFallbackName(_sRealName) : |
| | 0 | 1231 | | IcuGetConsoleFallbackName(_sRealName); |
| | | 1232 | | |
| | | 1233 | | /// <summary> |
| | | 1234 | | /// grouping of digits |
| | | 1235 | | /// (user can override) |
| | | 1236 | | /// </summary> |
| | 0 | 1237 | | internal int[] NumberGroupSizes => _waGrouping ??= GetLocaleInfoCoreUserOverride(LocaleGroupingData.Digit); |
| | | 1238 | | |
| | | 1239 | | /// <summary> |
| | | 1240 | | /// Not a Number |
| | | 1241 | | /// </summary> |
| | 0 | 1242 | | private string NaNSymbol => _sNaN ??= GetLocaleInfoCore(LocaleStringData.NaNSymbol); |
| | | 1243 | | |
| | | 1244 | | /// <summary> |
| | | 1245 | | /// + Infinity |
| | | 1246 | | /// </summary> |
| | 0 | 1247 | | private string PositiveInfinitySymbol => _sPositiveInfinity ??= GetLocaleInfoCore(LocaleStringData.PositiveInfin |
| | | 1248 | | |
| | | 1249 | | /// <summary> |
| | | 1250 | | /// - Infinity |
| | | 1251 | | /// </summary> |
| | 0 | 1252 | | private string NegativeInfinitySymbol => _sNegativeInfinity ??= GetLocaleInfoCore(LocaleStringData.NegativeInfin |
| | | 1253 | | |
| | | 1254 | | /// <summary> |
| | | 1255 | | /// Negative Percent (0-3) |
| | | 1256 | | /// </summary> |
| | | 1257 | | private int PercentNegativePattern |
| | | 1258 | | { |
| | | 1259 | | get |
| | | 1260 | | { |
| | 0 | 1261 | | if (_iNegativePercent == undef) |
| | | 1262 | | { |
| | | 1263 | | // Note that <= Windows Vista this is synthesized by native code |
| | 0 | 1264 | | _iNegativePercent = GetLocaleInfoCore(LocaleNumberData.NegativePercentFormat); |
| | | 1265 | | } |
| | 0 | 1266 | | return _iNegativePercent; |
| | | 1267 | | } |
| | | 1268 | | } |
| | | 1269 | | |
| | | 1270 | | /// <summary> |
| | | 1271 | | /// Positive Percent (0-11) |
| | | 1272 | | /// </summary> |
| | | 1273 | | private int PercentPositivePattern |
| | | 1274 | | { |
| | | 1275 | | get |
| | | 1276 | | { |
| | 0 | 1277 | | if (_iPositivePercent == undef) |
| | | 1278 | | { |
| | | 1279 | | // Note that <= Windows Vista this is synthesized by native code |
| | 0 | 1280 | | _iPositivePercent = GetLocaleInfoCore(LocaleNumberData.PositivePercentFormat); |
| | | 1281 | | } |
| | 0 | 1282 | | return _iPositivePercent; |
| | | 1283 | | } |
| | | 1284 | | } |
| | | 1285 | | |
| | | 1286 | | /// <summary> |
| | | 1287 | | /// Percent (%) symbol |
| | | 1288 | | /// </summary> |
| | 0 | 1289 | | private string PercentSymbol => _sPercent ??= GetLocaleInfoCore(LocaleStringData.PercentSymbol); |
| | | 1290 | | |
| | | 1291 | | /// <summary> |
| | | 1292 | | /// PerMille symbol |
| | | 1293 | | /// </summary> |
| | 0 | 1294 | | private string PerMilleSymbol => _sPerMille ??= GetLocaleInfoCore(LocaleStringData.PerMilleSymbol); |
| | | 1295 | | |
| | | 1296 | | /// <summary> |
| | | 1297 | | /// local monetary symbol, eg: $ |
| | | 1298 | | /// (user can override) |
| | | 1299 | | /// </summary> |
| | 0 | 1300 | | internal string CurrencySymbol => _sCurrency ??= GetLocaleInfoCoreUserOverride(LocaleStringData.MonetarySymbol); |
| | | 1301 | | |
| | | 1302 | | /// <summary> |
| | | 1303 | | /// international monetary symbol (RegionInfo), eg: USD |
| | | 1304 | | /// </summary> |
| | 0 | 1305 | | internal string ISOCurrencySymbol => _sIntlMonetarySymbol ??= GetLocaleInfoCore(LocaleStringData.Iso4217Monetary |
| | | 1306 | | |
| | | 1307 | | /// <summary> |
| | | 1308 | | /// English name for this currency (RegionInfo), eg: US Dollar |
| | | 1309 | | /// </summary> |
| | 0 | 1310 | | internal string CurrencyEnglishName => _sEnglishCurrency ??= GetLocaleInfoCore(LocaleStringData.CurrencyEnglishN |
| | | 1311 | | |
| | | 1312 | | /// <summary> |
| | | 1313 | | /// Native name for this currency (RegionInfo), eg: Schweiz Frank |
| | | 1314 | | /// </summary> |
| | 0 | 1315 | | internal string CurrencyNativeName => _sNativeCurrency ??= GetLocaleInfoCore(LocaleStringData.CurrencyNativeName |
| | | 1316 | | |
| | | 1317 | | /// <summary> |
| | | 1318 | | /// monetary grouping of digits |
| | | 1319 | | /// (user can override) |
| | | 1320 | | /// </summary> |
| | 0 | 1321 | | internal int[] CurrencyGroupSizes => _waMonetaryGrouping ??= GetLocaleInfoCoreUserOverride(LocaleGroupingData.Mo |
| | | 1322 | | |
| | | 1323 | | /// <summary> |
| | | 1324 | | /// system of measurement 0=metric, 1=US (RegionInfo) |
| | | 1325 | | /// (user can override) |
| | | 1326 | | /// </summary> |
| | | 1327 | | internal int MeasurementSystem |
| | | 1328 | | { |
| | | 1329 | | get |
| | | 1330 | | { |
| | 0 | 1331 | | if (_iMeasure == undef) |
| | | 1332 | | { |
| | 0 | 1333 | | _iMeasure = GetLocaleInfoCoreUserOverride(LocaleNumberData.MeasurementSystem); |
| | | 1334 | | } |
| | 0 | 1335 | | return _iMeasure; |
| | | 1336 | | } |
| | | 1337 | | } |
| | | 1338 | | |
| | | 1339 | | /// <summary> |
| | | 1340 | | /// list Separator |
| | | 1341 | | /// (user can override) |
| | | 1342 | | /// </summary> |
| | 0 | 1343 | | internal string ListSeparator => _sListSeparator ??= ShouldUseUserOverrideNlsData ? NlsGetLocaleInfo(LocaleStrin |
| | | 1344 | | |
| | | 1345 | | /// <summary> |
| | | 1346 | | /// AM designator |
| | | 1347 | | /// (user can override) |
| | | 1348 | | /// </summary> |
| | 0 | 1349 | | internal string AMDesignator => _sAM1159 ??= GetLocaleInfoCoreUserOverride(LocaleStringData.AMDesignator); |
| | | 1350 | | |
| | | 1351 | | /// <summary> |
| | | 1352 | | /// PM designator |
| | | 1353 | | /// (user can override) |
| | | 1354 | | /// </summary> |
| | 0 | 1355 | | internal string PMDesignator => _sPM2359 ??= GetLocaleInfoCoreUserOverride(LocaleStringData.PMDesignator); |
| | | 1356 | | |
| | | 1357 | | /// <summary> |
| | | 1358 | | /// time format |
| | | 1359 | | /// (user can override) |
| | | 1360 | | /// </summary> |
| | | 1361 | | internal string[] LongTimes |
| | | 1362 | | { |
| | | 1363 | | get |
| | | 1364 | | { |
| | 0 | 1365 | | if (_saLongTimes == null && !GlobalizationMode.Invariant) |
| | | 1366 | | { |
| | 0 | 1367 | | string[]? longTimes = GetTimeFormatsCore(shortFormat: false); |
| | 0 | 1368 | | _saLongTimes = longTimes != null && longTimes.Length != 0 ? longTimes : Invariant._saLongTimes!; |
| | | 1369 | | } |
| | | 1370 | | |
| | 0 | 1371 | | return _saLongTimes!; |
| | | 1372 | | } |
| | | 1373 | | } |
| | | 1374 | | |
| | | 1375 | | /// <summary> |
| | | 1376 | | /// Short times (derived from long times format) |
| | | 1377 | | /// (user can override) |
| | | 1378 | | /// </summary> |
| | | 1379 | | internal string[] ShortTimes |
| | | 1380 | | { |
| | | 1381 | | get |
| | | 1382 | | { |
| | 0 | 1383 | | if (_saShortTimes == null && !GlobalizationMode.Invariant) |
| | | 1384 | | { |
| | | 1385 | | // Try to get the short times from the OS/culture.dll |
| | | 1386 | | // If we couldn't find short times, then compute them from long times |
| | | 1387 | | // (eg: CORECLR on < Win7 OS & fallback for missing culture.dll) |
| | 0 | 1388 | | string[]? shortTimes = GetTimeFormatsCore(shortFormat: true); |
| | 0 | 1389 | | _saShortTimes = shortTimes != null && shortTimes.Length != 0 ? shortTimes : DeriveShortTimesFromLong |
| | | 1390 | | } |
| | | 1391 | | |
| | 0 | 1392 | | return _saShortTimes!; |
| | | 1393 | | } |
| | | 1394 | | } |
| | | 1395 | | |
| | | 1396 | | private string[] DeriveShortTimesFromLong() |
| | | 1397 | | { |
| | | 1398 | | // Our logic is to look for h,H,m,s,t. If we find an s, then we check the string |
| | | 1399 | | // between it and the previous marker, if any. If its a short, unescaped separator, |
| | | 1400 | | // then we don't retain that part. |
| | | 1401 | | // We then check after the ss and remove anything before the next h,H,m,t... |
| | 0 | 1402 | | string[] longTimes = LongTimes; |
| | 0 | 1403 | | string[] shortTimes = new string[longTimes.Length]; |
| | | 1404 | | |
| | 0 | 1405 | | for (int i = 0; i < longTimes.Length; i++) |
| | | 1406 | | { |
| | 0 | 1407 | | shortTimes[i] = StripSecondsFromPattern(longTimes[i]); |
| | | 1408 | | } |
| | 0 | 1409 | | return shortTimes; |
| | | 1410 | | } |
| | | 1411 | | |
| | | 1412 | | private static string StripSecondsFromPattern(string time) |
| | | 1413 | | { |
| | 0 | 1414 | | bool bEscape = false; |
| | 0 | 1415 | | int iLastToken = -1; |
| | | 1416 | | |
| | | 1417 | | // Find the seconds |
| | 0 | 1418 | | for (int j = 0; j < time.Length; j++) |
| | | 1419 | | { |
| | | 1420 | | // Change escape mode? |
| | 0 | 1421 | | if (time[j] == '\'') |
| | | 1422 | | { |
| | | 1423 | | // Continue |
| | 0 | 1424 | | bEscape = !bEscape; |
| | 0 | 1425 | | continue; |
| | | 1426 | | } |
| | | 1427 | | |
| | | 1428 | | // See if there was a single \ |
| | 0 | 1429 | | if (time[j] == '\\') |
| | | 1430 | | { |
| | | 1431 | | // Skip next char |
| | 0 | 1432 | | j++; |
| | 0 | 1433 | | continue; |
| | | 1434 | | } |
| | | 1435 | | |
| | 0 | 1436 | | if (bEscape) |
| | | 1437 | | { |
| | | 1438 | | continue; |
| | | 1439 | | } |
| | | 1440 | | |
| | 0 | 1441 | | switch (time[j]) |
| | | 1442 | | { |
| | | 1443 | | // Check for seconds |
| | | 1444 | | case 's': |
| | | 1445 | | // Found seconds, see if there was something unescaped and short between |
| | | 1446 | | // the last marker and the seconds. Windows says separator can be a |
| | | 1447 | | // maximum of three characters (without null) |
| | | 1448 | | // If 1st or last characters were ', then ignore it |
| | 0 | 1449 | | if ((j - iLastToken) <= 4 && (j - iLastToken) > 1 && |
| | 0 | 1450 | | (time[iLastToken + 1] != '\'') && |
| | 0 | 1451 | | (time[j - 1] != '\'')) |
| | | 1452 | | { |
| | | 1453 | | // There was something there we want to remember |
| | 0 | 1454 | | if (iLastToken >= 0) |
| | | 1455 | | { |
| | 0 | 1456 | | j = iLastToken + 1; |
| | | 1457 | | } |
| | | 1458 | | } |
| | | 1459 | | |
| | | 1460 | | bool containsSpace; |
| | 0 | 1461 | | int endIndex = GetIndexOfNextTokenAfterSeconds(time, j, out containsSpace); |
| | | 1462 | | |
| | | 1463 | | string sep; |
| | | 1464 | | |
| | 0 | 1465 | | if (containsSpace) |
| | | 1466 | | { |
| | 0 | 1467 | | sep = " "; |
| | | 1468 | | } |
| | | 1469 | | else |
| | | 1470 | | { |
| | 0 | 1471 | | sep = ""; |
| | | 1472 | | } |
| | | 1473 | | |
| | 0 | 1474 | | time = string.Concat(time.AsSpan(0, j), sep, time.AsSpan(endIndex)); |
| | 0 | 1475 | | break; |
| | | 1476 | | case 'm': |
| | | 1477 | | case 'H': |
| | | 1478 | | case 'h': |
| | 0 | 1479 | | iLastToken = j; |
| | | 1480 | | break; |
| | | 1481 | | } |
| | | 1482 | | } |
| | 0 | 1483 | | return time; |
| | | 1484 | | } |
| | | 1485 | | |
| | | 1486 | | private static int GetIndexOfNextTokenAfterSeconds(string time, int index, out bool containsSpace) |
| | | 1487 | | { |
| | 0 | 1488 | | bool shouldEscape = false; |
| | 0 | 1489 | | containsSpace = false; |
| | 0 | 1490 | | for (; index < time.Length; index++) |
| | | 1491 | | { |
| | 0 | 1492 | | switch (time[index]) |
| | | 1493 | | { |
| | | 1494 | | case '\'': |
| | 0 | 1495 | | shouldEscape = !shouldEscape; |
| | 0 | 1496 | | continue; |
| | | 1497 | | case '\\': |
| | 0 | 1498 | | index++; |
| | 0 | 1499 | | if (time[index] == ' ') |
| | | 1500 | | { |
| | 0 | 1501 | | containsSpace = true; |
| | | 1502 | | } |
| | 0 | 1503 | | continue; |
| | | 1504 | | case ' ': |
| | 0 | 1505 | | containsSpace = true; |
| | 0 | 1506 | | break; |
| | | 1507 | | case 't': |
| | | 1508 | | case 'm': |
| | | 1509 | | case 'H': |
| | | 1510 | | case 'h': |
| | 0 | 1511 | | if (shouldEscape) |
| | | 1512 | | { |
| | | 1513 | | continue; |
| | | 1514 | | } |
| | 0 | 1515 | | return index; |
| | | 1516 | | } |
| | | 1517 | | } |
| | 0 | 1518 | | containsSpace = false; |
| | 0 | 1519 | | return index; |
| | | 1520 | | } |
| | | 1521 | | |
| | | 1522 | | /// <summary> |
| | | 1523 | | /// first day of week |
| | | 1524 | | /// (user can override) |
| | | 1525 | | /// </summary> |
| | | 1526 | | internal int FirstDayOfWeek |
| | | 1527 | | { |
| | | 1528 | | get |
| | | 1529 | | { |
| | 0 | 1530 | | if (_iFirstDayOfWeek == undef && !GlobalizationMode.Invariant) |
| | | 1531 | | { |
| | | 1532 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 1533 | | if (GlobalizationMode.Hybrid) |
| | | 1534 | | { |
| | | 1535 | | _iFirstDayOfWeek = GetLocaleInfoNative(LocaleNumberData.FirstDayOfWeek); |
| | | 1536 | | } |
| | | 1537 | | else |
| | | 1538 | | #endif |
| | | 1539 | | { |
| | 0 | 1540 | | _iFirstDayOfWeek = ShouldUseUserOverrideNlsData ? NlsGetFirstDayOfWeek() : IcuGetLocaleInfo(Loca |
| | | 1541 | | } |
| | | 1542 | | } |
| | 0 | 1543 | | return _iFirstDayOfWeek; |
| | | 1544 | | } |
| | | 1545 | | } |
| | | 1546 | | |
| | | 1547 | | /// <summary> |
| | | 1548 | | /// first week of year |
| | | 1549 | | /// (user can override) |
| | | 1550 | | /// </summary> |
| | | 1551 | | internal int CalendarWeekRule |
| | | 1552 | | { |
| | | 1553 | | get |
| | | 1554 | | { |
| | 0 | 1555 | | if (_iFirstWeekOfYear == undef) |
| | | 1556 | | { |
| | 0 | 1557 | | _iFirstWeekOfYear = GetLocaleInfoCoreUserOverride(LocaleNumberData.FirstWeekOfYear); |
| | | 1558 | | } |
| | 0 | 1559 | | return _iFirstWeekOfYear; |
| | | 1560 | | } |
| | | 1561 | | } |
| | | 1562 | | |
| | | 1563 | | /// <summary> |
| | | 1564 | | /// (user can override default only) short date format |
| | | 1565 | | /// </summary> |
| | | 1566 | | internal string[] ShortDates(CalendarId calendarId) |
| | | 1567 | | { |
| | 0 | 1568 | | return GetCalendar(calendarId).saShortDates; |
| | | 1569 | | } |
| | | 1570 | | |
| | | 1571 | | /// <summary> |
| | | 1572 | | /// long date format |
| | | 1573 | | /// (user can override default only) |
| | | 1574 | | /// </summary> |
| | | 1575 | | internal string[] LongDates(CalendarId calendarId) |
| | | 1576 | | { |
| | 0 | 1577 | | return GetCalendar(calendarId).saLongDates; |
| | | 1578 | | } |
| | | 1579 | | |
| | | 1580 | | /// <summary> |
| | | 1581 | | /// date year/month format. |
| | | 1582 | | /// (user can override default only) |
| | | 1583 | | /// </summary> |
| | | 1584 | | internal string[] YearMonths(CalendarId calendarId) |
| | | 1585 | | { |
| | 0 | 1586 | | return GetCalendar(calendarId).saYearMonths; |
| | | 1587 | | } |
| | | 1588 | | |
| | | 1589 | | internal string[] DayNames(CalendarId calendarId) |
| | | 1590 | | { |
| | 0 | 1591 | | return GetCalendar(calendarId).saDayNames; |
| | | 1592 | | } |
| | | 1593 | | |
| | | 1594 | | internal string[] AbbreviatedDayNames(CalendarId calendarId) |
| | | 1595 | | { |
| | 0 | 1596 | | return GetCalendar(calendarId).saAbbrevDayNames; |
| | | 1597 | | } |
| | | 1598 | | |
| | | 1599 | | internal string[] SuperShortDayNames(CalendarId calendarId) |
| | | 1600 | | { |
| | 0 | 1601 | | return GetCalendar(calendarId).saSuperShortDayNames; |
| | | 1602 | | } |
| | | 1603 | | |
| | | 1604 | | internal string[] MonthNames(CalendarId calendarId) |
| | | 1605 | | { |
| | 0 | 1606 | | return GetCalendar(calendarId).saMonthNames; |
| | | 1607 | | } |
| | | 1608 | | |
| | | 1609 | | internal string[] GenitiveMonthNames(CalendarId calendarId) |
| | | 1610 | | { |
| | 0 | 1611 | | return GetCalendar(calendarId).saMonthGenitiveNames; |
| | | 1612 | | } |
| | | 1613 | | |
| | | 1614 | | internal string[] AbbreviatedMonthNames(CalendarId calendarId) |
| | | 1615 | | { |
| | 0 | 1616 | | return GetCalendar(calendarId).saAbbrevMonthNames; |
| | | 1617 | | } |
| | | 1618 | | |
| | | 1619 | | internal string[] AbbreviatedGenitiveMonthNames(CalendarId calendarId) |
| | | 1620 | | { |
| | 0 | 1621 | | return GetCalendar(calendarId).saAbbrevMonthGenitiveNames; |
| | | 1622 | | } |
| | | 1623 | | |
| | | 1624 | | /// <remarks>> |
| | | 1625 | | /// Note: This only applies to Hebrew, and it basically adds a "1" to the 6th month name |
| | | 1626 | | /// the non-leap names skip the 7th name in the normal month name array |
| | | 1627 | | /// </remarks> |
| | | 1628 | | internal string[] LeapYearMonthNames(CalendarId calendarId) |
| | | 1629 | | { |
| | 0 | 1630 | | return GetCalendar(calendarId).saLeapYearMonthNames; |
| | | 1631 | | } |
| | | 1632 | | |
| | | 1633 | | internal string MonthDay(CalendarId calendarId) |
| | | 1634 | | { |
| | 0 | 1635 | | return GetCalendar(calendarId).sMonthDay; |
| | | 1636 | | } |
| | | 1637 | | |
| | | 1638 | | /// <summary> |
| | | 1639 | | /// All available calendar type(s). The first one is the default calendar. |
| | | 1640 | | /// </summary> |
| | | 1641 | | internal CalendarId[] CalendarIds |
| | | 1642 | | { |
| | | 1643 | | get |
| | | 1644 | | { |
| | 0 | 1645 | | if (_waCalendars == null) |
| | | 1646 | | { |
| | 0 | 1647 | | if (GlobalizationMode.Invariant || IsInvariantCulture) |
| | | 1648 | | { |
| | | 1649 | | // We do this lazily as opposed in CreateCultureWithInvariantData to avoid introducing |
| | | 1650 | | // enum arrays into apps that otherwise wouldn't have them. This helps with size in AOT. |
| | 0 | 1651 | | _waCalendars = [CalendarId.GREGORIAN]; |
| | | 1652 | | } |
| | | 1653 | | else |
| | | 1654 | | { |
| | | 1655 | | // We pass in an array of ints, and native side fills it up with count calendars. |
| | | 1656 | | // We then have to copy that list to a new array of the right size. |
| | | 1657 | | // Default calendar should be first |
| | 0 | 1658 | | CalendarId[] calendars = new CalendarId[23]; |
| | 0 | 1659 | | Debug.Assert(_sWindowsName != null, "[CultureData.CalendarIds] Expected _sWindowsName to be popu |
| | | 1660 | | |
| | 0 | 1661 | | int count = CalendarData.GetCalendarsCore(_sWindowsName, _bUseOverrides, calendars); |
| | | 1662 | | |
| | | 1663 | | // See if we had a calendar to add. |
| | 0 | 1664 | | if (count == 0) |
| | | 1665 | | { |
| | | 1666 | | // Failed for some reason, just use Gregorian |
| | 0 | 1667 | | _waCalendars = Invariant.CalendarIds; |
| | | 1668 | | } |
| | | 1669 | | else |
| | | 1670 | | { |
| | | 1671 | | // The OS may not return calendar 4 for zh-TW, but we've always allowed it. |
| | | 1672 | | // TODO: Is this hack necessary long-term? |
| | 0 | 1673 | | if (_sWindowsName == "zh-TW") |
| | | 1674 | | { |
| | 0 | 1675 | | bool found = false; |
| | | 1676 | | |
| | | 1677 | | // Do we need to insert calendar 4? |
| | 0 | 1678 | | for (int i = 0; i < count; i++) |
| | | 1679 | | { |
| | | 1680 | | // Stop if we found calendar four |
| | 0 | 1681 | | if (calendars[i] == CalendarId.TAIWAN) |
| | | 1682 | | { |
| | 0 | 1683 | | found = true; |
| | 0 | 1684 | | break; |
| | | 1685 | | } |
| | | 1686 | | } |
| | | 1687 | | |
| | | 1688 | | // If not found then insert it |
| | 0 | 1689 | | if (!found) |
| | | 1690 | | { |
| | | 1691 | | // Insert it as the 2nd calendar |
| | 0 | 1692 | | count++; |
| | | 1693 | | // Copy them from the 2nd position to the end, -1 for skipping 1st, -1 for one being |
| | 0 | 1694 | | Array.Copy(calendars, 1, calendars, 2, 23 - 1 - 1); |
| | 0 | 1695 | | calendars[1] = CalendarId.TAIWAN; |
| | | 1696 | | } |
| | | 1697 | | } |
| | | 1698 | | |
| | | 1699 | | // It worked, remember the list |
| | 0 | 1700 | | CalendarId[] temp = new CalendarId[count]; |
| | 0 | 1701 | | Array.Copy(calendars, temp, count); |
| | 0 | 1702 | | _waCalendars = temp; |
| | | 1703 | | } |
| | | 1704 | | } |
| | | 1705 | | } |
| | 0 | 1706 | | return _waCalendars; |
| | | 1707 | | } |
| | | 1708 | | } |
| | | 1709 | | |
| | | 1710 | | /// <summary> |
| | | 1711 | | /// Native calendar names. Index of optional calendar - 1, empty if |
| | | 1712 | | /// no optional calendar at that number |
| | | 1713 | | /// </summary> |
| | | 1714 | | internal string CalendarName(CalendarId calendarId) |
| | | 1715 | | { |
| | 0 | 1716 | | return GetCalendar(calendarId).sNativeName; |
| | | 1717 | | } |
| | | 1718 | | |
| | | 1719 | | internal CalendarData GetCalendar(CalendarId calendarId) |
| | | 1720 | | { |
| | 0 | 1721 | | if (GlobalizationMode.Invariant) |
| | | 1722 | | { |
| | 0 | 1723 | | return CalendarData.Invariant; |
| | | 1724 | | } |
| | | 1725 | | |
| | 0 | 1726 | | Debug.Assert(calendarId > 0 && calendarId <= CalendarId.LAST_CALENDAR, |
| | 0 | 1727 | | "[CultureData.GetCalendar] Expect calendarId to be in a valid range"); |
| | | 1728 | | |
| | | 1729 | | // arrays are 0 based, calendarIds are 1 based |
| | 0 | 1730 | | int calendarIndex = (int)calendarId - 1; |
| | | 1731 | | |
| | | 1732 | | // Have to have calendars |
| | 0 | 1733 | | _calendars ??= new CalendarData[CalendarData.MAX_CALENDARS]; |
| | | 1734 | | |
| | | 1735 | | // we need the following local variable to avoid returning null |
| | | 1736 | | // when another thread creates a new array of CalendarData (above) |
| | | 1737 | | // right after we insert the newly created CalendarData (below) |
| | 0 | 1738 | | CalendarData? calendarData = _calendars[calendarIndex]; |
| | | 1739 | | // Make sure that calendar has data |
| | 0 | 1740 | | if (calendarData == null) |
| | | 1741 | | { |
| | 0 | 1742 | | if (calendarIndex == 0 && IsInvariantCulture) |
| | | 1743 | | { |
| | | 1744 | | // We do this lazily as opposed in CreateCultureWithInvariantData to avoid introducing |
| | | 1745 | | // invariant calendar data into apps that don't even need calendar. |
| | 0 | 1746 | | calendarData = CalendarData.Invariant; |
| | | 1747 | | } |
| | | 1748 | | else |
| | | 1749 | | { |
| | 0 | 1750 | | Debug.Assert(_sWindowsName != null, "[CultureData.GetCalendar] Expected _sWindowsName to be populate |
| | 0 | 1751 | | calendarData = new CalendarData(_sWindowsName, calendarId, _bUseOverrides); |
| | | 1752 | | } |
| | 0 | 1753 | | _calendars[calendarIndex] = calendarData; |
| | | 1754 | | } |
| | | 1755 | | |
| | 0 | 1756 | | return calendarData; |
| | | 1757 | | } |
| | | 1758 | | |
| | | 1759 | | internal bool IsRightToLeft => |
| | | 1760 | | // Returns one of the following 4 reading layout values: |
| | | 1761 | | // 0 - Left to right (eg en-US) |
| | | 1762 | | // 1 - Right to left (eg arabic locales) |
| | | 1763 | | // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) |
| | | 1764 | | // 3 - Vertical top to bottom with columns proceeding to the right |
| | 0 | 1765 | | ReadingLayout == 1; |
| | | 1766 | | |
| | | 1767 | | /// <summary> |
| | | 1768 | | /// Returns one of the following 4 reading layout values: |
| | | 1769 | | /// 0 - Left to right (eg en-US) |
| | | 1770 | | /// 1 - Right to left (eg arabic locales) |
| | | 1771 | | /// 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) |
| | | 1772 | | /// 3 - Vertical top to bottom with columns proceeding to the right |
| | | 1773 | | /// </summary> |
| | | 1774 | | private int ReadingLayout |
| | | 1775 | | { |
| | | 1776 | | get |
| | | 1777 | | { |
| | 0 | 1778 | | if (_iReadingLayout == undef && !GlobalizationMode.Invariant) |
| | | 1779 | | { |
| | 0 | 1780 | | Debug.Assert(_sRealName != null, "[CultureData.IsRightToLeft] Expected _sRealName to be populated by |
| | 0 | 1781 | | _iReadingLayout = GetLocaleInfoCore(LocaleNumberData.ReadingLayout); |
| | | 1782 | | } |
| | | 1783 | | |
| | 0 | 1784 | | return _iReadingLayout; |
| | | 1785 | | } |
| | | 1786 | | } |
| | | 1787 | | |
| | | 1788 | | /// <summary> |
| | | 1789 | | /// // Text info name to use for text information |
| | | 1790 | | /// The TextInfo name never includes that alternate sort and is always specific |
| | | 1791 | | /// For customs, it uses the SortLocale (since the textinfo is not exposed in Win7) |
| | | 1792 | | /// en -> en-US |
| | | 1793 | | /// en-US -> en-US |
| | | 1794 | | /// fj (custom neutral) -> en-US (assuming that en-US is the sort locale for fj) |
| | | 1795 | | /// fj_FJ (custom specific) -> en-US (assuming that en-US is the sort locale for fj-FJ) |
| | | 1796 | | /// es-ES_tradnl -> es-ES |
| | | 1797 | | /// </summary> |
| | | 1798 | | internal string TextInfoName |
| | | 1799 | | { |
| | | 1800 | | get |
| | | 1801 | | { |
| | | 1802 | | // Note: Custom cultures might point at another culture's textinfo, however windows knows how |
| | | 1803 | | // to redirect it to the desired textinfo culture, so this is OK. |
| | 0 | 1804 | | Debug.Assert(_sRealName != null, "[CultureData.TextInfoName] Expected _sRealName to be populated by alre |
| | 0 | 1805 | | return _sRealName; |
| | | 1806 | | } |
| | | 1807 | | } |
| | | 1808 | | |
| | | 1809 | | /// <summary> |
| | | 1810 | | /// Compare info name (including sorting key) to use if custom |
| | | 1811 | | /// </summary> |
| | | 1812 | | internal string SortName |
| | | 1813 | | { |
| | | 1814 | | get |
| | | 1815 | | { |
| | 0 | 1816 | | Debug.Assert(_sRealName != null, "[CultureData.SortName] Expected _sRealName to be populated by already" |
| | 0 | 1817 | | return _sRealName; |
| | | 1818 | | } |
| | | 1819 | | } |
| | | 1820 | | |
| | 0 | 1821 | | internal bool IsSupplementalCustomCulture => IsCustomCultureId(LCID); |
| | | 1822 | | |
| | | 1823 | | /// <summary> |
| | | 1824 | | /// Default ansi code page ID (ACP) |
| | | 1825 | | /// </summary> |
| | | 1826 | | internal int ANSICodePage |
| | | 1827 | | { |
| | | 1828 | | get |
| | | 1829 | | { |
| | 0 | 1830 | | if (_iDefaultAnsiCodePage == undef && !GlobalizationMode.Invariant) |
| | | 1831 | | { |
| | 0 | 1832 | | _iDefaultAnsiCodePage = GetAnsiCodePage(_sRealName); |
| | | 1833 | | } |
| | 0 | 1834 | | return _iDefaultAnsiCodePage; |
| | | 1835 | | } |
| | | 1836 | | } |
| | | 1837 | | |
| | | 1838 | | /// <summary> |
| | | 1839 | | /// Default oem code page ID (OCP or OEM). |
| | | 1840 | | /// </summary> |
| | | 1841 | | internal int OEMCodePage |
| | | 1842 | | { |
| | | 1843 | | get |
| | | 1844 | | { |
| | 0 | 1845 | | if (_iDefaultOemCodePage == undef && !GlobalizationMode.Invariant) |
| | | 1846 | | { |
| | 0 | 1847 | | _iDefaultOemCodePage = GetOemCodePage(_sRealName); |
| | | 1848 | | } |
| | 0 | 1849 | | return _iDefaultOemCodePage; |
| | | 1850 | | } |
| | | 1851 | | } |
| | | 1852 | | |
| | | 1853 | | /// <summary> |
| | | 1854 | | /// Default macintosh code page. |
| | | 1855 | | /// </summary> |
| | | 1856 | | internal int MacCodePage |
| | | 1857 | | { |
| | | 1858 | | get |
| | | 1859 | | { |
| | 0 | 1860 | | if (_iDefaultMacCodePage == undef && !GlobalizationMode.Invariant) |
| | | 1861 | | { |
| | 0 | 1862 | | _iDefaultMacCodePage = GetMacCodePage(_sRealName); |
| | | 1863 | | } |
| | 0 | 1864 | | return _iDefaultMacCodePage; |
| | | 1865 | | } |
| | | 1866 | | } |
| | | 1867 | | |
| | | 1868 | | /// <summary> |
| | | 1869 | | /// Default EBCDIC code page. |
| | | 1870 | | /// </summary> |
| | | 1871 | | internal int EBCDICCodePage |
| | | 1872 | | { |
| | | 1873 | | get |
| | | 1874 | | { |
| | 0 | 1875 | | if (_iDefaultEbcdicCodePage == undef && !GlobalizationMode.Invariant) |
| | | 1876 | | { |
| | 0 | 1877 | | _iDefaultEbcdicCodePage = GetEbcdicCodePage(_sRealName); |
| | | 1878 | | } |
| | 0 | 1879 | | return _iDefaultEbcdicCodePage; |
| | | 1880 | | } |
| | | 1881 | | } |
| | | 1882 | | |
| | | 1883 | | internal int LCID |
| | | 1884 | | { |
| | | 1885 | | get |
| | | 1886 | | { |
| | 0 | 1887 | | if (_iLanguage == 0 && !GlobalizationMode.Invariant) |
| | | 1888 | | { |
| | 0 | 1889 | | Debug.Assert(_sRealName != null, "[CultureData.LCID] Expected this.sRealName to be populated already |
| | 0 | 1890 | | _iLanguage = GlobalizationMode.UseNls ? NlsLocaleNameToLCID(_sRealName) : IcuLocaleNameToLCID(_sReal |
| | | 1891 | | } |
| | 0 | 1892 | | return _iLanguage; |
| | | 1893 | | } |
| | | 1894 | | } |
| | | 1895 | | |
| | | 1896 | | internal bool IsNeutralCulture => |
| | | 1897 | | // InitCultureData told us if we're neutral or not |
| | 0 | 1898 | | _bNeutral; |
| | | 1899 | | |
| | 0 | 1900 | | internal bool IsInvariantCulture => string.IsNullOrEmpty(Name); |
| | | 1901 | | |
| | 0 | 1902 | | internal bool IsReplacementCulture => GlobalizationMode.UseNls ? NlsIsReplacementCulture : false; |
| | | 1903 | | |
| | | 1904 | | /// <summary> |
| | | 1905 | | /// Get an instance of our default calendar |
| | | 1906 | | /// </summary> |
| | | 1907 | | internal Calendar DefaultCalendar |
| | | 1908 | | { |
| | | 1909 | | get |
| | | 1910 | | { |
| | 0 | 1911 | | if (GlobalizationMode.Invariant) |
| | | 1912 | | { |
| | 0 | 1913 | | return new GregorianCalendar(); |
| | | 1914 | | } |
| | | 1915 | | |
| | 0 | 1916 | | CalendarId defaultCalId = (CalendarId)GetLocaleInfoCore(LocaleNumberData.CalendarType); |
| | | 1917 | | |
| | 0 | 1918 | | if (defaultCalId == 0) |
| | | 1919 | | { |
| | 0 | 1920 | | defaultCalId = CalendarIds[0]; |
| | | 1921 | | } |
| | | 1922 | | |
| | 0 | 1923 | | return CultureInfo.GetCalendarInstance(defaultCalId); |
| | | 1924 | | } |
| | | 1925 | | } |
| | | 1926 | | |
| | | 1927 | | /// <summary> |
| | | 1928 | | /// All of our era names |
| | | 1929 | | /// </summary> |
| | | 1930 | | internal string[] EraNames(CalendarId calendarId) |
| | | 1931 | | { |
| | 0 | 1932 | | Debug.Assert(calendarId > 0, "[CultureData.saEraNames] Expected Calendar.ID > 0"); |
| | 0 | 1933 | | return GetCalendar(calendarId).saEraNames; |
| | | 1934 | | } |
| | | 1935 | | |
| | | 1936 | | internal string[] AbbrevEraNames(CalendarId calendarId) |
| | | 1937 | | { |
| | 0 | 1938 | | Debug.Assert(calendarId > 0, "[CultureData.saAbbrevEraNames] Expected Calendar.ID > 0"); |
| | 0 | 1939 | | return GetCalendar(calendarId).saAbbrevEraNames; |
| | | 1940 | | } |
| | | 1941 | | |
| | | 1942 | | internal string[] AbbreviatedEnglishEraNames(CalendarId calendarId) |
| | | 1943 | | { |
| | 0 | 1944 | | Debug.Assert(calendarId > 0, "[CultureData.saAbbrevEraNames] Expected Calendar.ID > 0"); |
| | 0 | 1945 | | return GetCalendar(calendarId).saAbbrevEnglishEraNames; |
| | | 1946 | | } |
| | | 1947 | | |
| | | 1948 | | /// <summary> |
| | | 1949 | | /// Time separator (derived from time format) |
| | | 1950 | | /// </summary> |
| | | 1951 | | internal string TimeSeparator |
| | | 1952 | | { |
| | | 1953 | | get |
| | | 1954 | | { |
| | 0 | 1955 | | if (_sTimeSeparator == null && !GlobalizationMode.Invariant) |
| | | 1956 | | { |
| | | 1957 | | // fr-CA culture uses time format as "HH 'h' mm 'min' ss 's'" which we cannot derive the time separa |
| | | 1958 | | // We special case such culture and force ':' as time separator. |
| | 0 | 1959 | | if (_sName == "fr-CA") |
| | | 1960 | | { |
| | 0 | 1961 | | _sTimeSeparator = ":"; |
| | | 1962 | | } |
| | | 1963 | | else |
| | | 1964 | | { |
| | 0 | 1965 | | string? longTimeFormat = ShouldUseUserOverrideNlsData ? NlsGetTimeFormatString() : IcuGetTimeFor |
| | 0 | 1966 | | if (string.IsNullOrEmpty(longTimeFormat)) |
| | | 1967 | | { |
| | 0 | 1968 | | longTimeFormat = LongTimes[0]; |
| | | 1969 | | } |
| | | 1970 | | |
| | | 1971 | | // Compute STIME from time format |
| | 0 | 1972 | | _sTimeSeparator = GetTimeSeparator(longTimeFormat); |
| | | 1973 | | } |
| | | 1974 | | } |
| | 0 | 1975 | | return _sTimeSeparator!; |
| | | 1976 | | } |
| | | 1977 | | } |
| | | 1978 | | |
| | | 1979 | | /// <summary> |
| | | 1980 | | /// Date separator (derived from short date format) |
| | | 1981 | | /// </summary> |
| | | 1982 | | internal string DateSeparator(CalendarId calendarId) |
| | | 1983 | | { |
| | 0 | 1984 | | if (GlobalizationMode.Invariant) |
| | | 1985 | | { |
| | 0 | 1986 | | return "/"; |
| | | 1987 | | } |
| | | 1988 | | |
| | 0 | 1989 | | if (calendarId == CalendarId.JAPAN && !LocalAppContextSwitches.EnforceLegacyJapaneseDateParsing) |
| | | 1990 | | { |
| | | 1991 | | // The date separator is derived from the default short date pattern. So far this pattern is using |
| | | 1992 | | // '/' as date separator when using the Japanese calendar which make the formatting and parsing work fin |
| | | 1993 | | // changing the default pattern is likely will happen in the near future which can easily break formatti |
| | | 1994 | | // and parsing. |
| | | 1995 | | // We are forcing here the date separator to '/' to ensure the parsing is not going to break when changi |
| | | 1996 | | // the default short date pattern. The application still can override this in the code by DateTimeFormat |
| | 0 | 1997 | | return "/"; |
| | | 1998 | | } |
| | | 1999 | | |
| | 0 | 2000 | | return GetDateSeparator(ShortDates(calendarId)[0]); |
| | | 2001 | | } |
| | | 2002 | | |
| | | 2003 | | /// <summary> |
| | | 2004 | | /// Unescape a NLS style quote string |
| | | 2005 | | /// |
| | | 2006 | | /// This removes single quotes: |
| | | 2007 | | /// 'fred' -> fred |
| | | 2008 | | /// 'fred -> fred |
| | | 2009 | | /// fred' -> fred |
| | | 2010 | | /// fred's -> freds |
| | | 2011 | | /// |
| | | 2012 | | /// This removes the first \ of escaped characters: |
| | | 2013 | | /// fred\'s -> fred's |
| | | 2014 | | /// a\\b -> a\b |
| | | 2015 | | /// a\b -> ab |
| | | 2016 | | /// |
| | | 2017 | | /// We don't build the stringbuilder unless we find a ' or a \. If we find a ' or a \, we |
| | | 2018 | | /// always build a stringbuilder because we need to remove the ' or \. |
| | | 2019 | | /// </summary> |
| | | 2020 | | private static string UnescapeNlsString(string str, int start, int end) |
| | | 2021 | | { |
| | 0 | 2022 | | Debug.Assert(str != null); |
| | 0 | 2023 | | Debug.Assert(start >= 0); |
| | 0 | 2024 | | Debug.Assert(end >= 0); |
| | 0 | 2025 | | StringBuilder? result = null; |
| | | 2026 | | |
| | 0 | 2027 | | for (int i = start; i < str.Length && i <= end; i++) |
| | | 2028 | | { |
| | 0 | 2029 | | switch (str[i]) |
| | | 2030 | | { |
| | | 2031 | | case '\'': |
| | 0 | 2032 | | result ??= new StringBuilder(str, start, i - start, str.Length); |
| | 0 | 2033 | | break; |
| | | 2034 | | case '\\': |
| | 0 | 2035 | | result ??= new StringBuilder(str, start, i - start, str.Length); |
| | 0 | 2036 | | ++i; |
| | 0 | 2037 | | if (i < str.Length) |
| | | 2038 | | { |
| | 0 | 2039 | | result.Append(str[i]); |
| | | 2040 | | } |
| | 0 | 2041 | | break; |
| | | 2042 | | default: |
| | 0 | 2043 | | result?.Append(str[i]); |
| | | 2044 | | break; |
| | | 2045 | | } |
| | | 2046 | | } |
| | | 2047 | | |
| | 0 | 2048 | | if (result == null) |
| | | 2049 | | { |
| | 0 | 2050 | | return str.Substring(start, end - start + 1); |
| | | 2051 | | } |
| | | 2052 | | |
| | 0 | 2053 | | return result.ToString(); |
| | | 2054 | | } |
| | | 2055 | | |
| | | 2056 | | /// <summary> |
| | | 2057 | | /// Time format separator (ie: : in 12:39:00) |
| | | 2058 | | /// We calculate this from the provided time format |
| | | 2059 | | /// </summary> |
| | | 2060 | | private static string GetTimeSeparator(string format) |
| | | 2061 | | { |
| | | 2062 | | // Find the time separator so that we can pretend we know TimeSeparator. |
| | 0 | 2063 | | return GetSeparator(format, "Hhms"); |
| | | 2064 | | } |
| | | 2065 | | |
| | | 2066 | | /// <summary> |
| | | 2067 | | /// Date format separator (ie: / in 9/1/03) |
| | | 2068 | | /// We calculate this from the provided short date |
| | | 2069 | | /// </summary> |
| | | 2070 | | private static string GetDateSeparator(string format) |
| | | 2071 | | { |
| | | 2072 | | // Find the date separator so that we can pretend we know DateSeparator. |
| | 0 | 2073 | | return GetSeparator(format, "dyM"); |
| | | 2074 | | } |
| | | 2075 | | |
| | | 2076 | | private static string GetSeparator(string format, string timeParts) |
| | | 2077 | | { |
| | 0 | 2078 | | int index = IndexOfTimePart(format, 0, timeParts); |
| | | 2079 | | |
| | 0 | 2080 | | if (index != -1) |
| | | 2081 | | { |
| | | 2082 | | // Found a time part, find out when it changes |
| | 0 | 2083 | | char cTimePart = format[index]; |
| | | 2084 | | |
| | | 2085 | | do |
| | | 2086 | | { |
| | 0 | 2087 | | index++; |
| | 0 | 2088 | | } while (index < format.Length && format[index] == cTimePart); |
| | | 2089 | | |
| | 0 | 2090 | | int separatorStart = index; |
| | | 2091 | | |
| | | 2092 | | // Now we need to find the end of the separator |
| | 0 | 2093 | | if (separatorStart < format.Length) |
| | | 2094 | | { |
| | 0 | 2095 | | int separatorEnd = IndexOfTimePart(format, separatorStart, timeParts); |
| | 0 | 2096 | | if (separatorEnd != -1) |
| | | 2097 | | { |
| | | 2098 | | // From [separatorStart, count) is our string, except we need to unescape |
| | 0 | 2099 | | return UnescapeNlsString(format, separatorStart, separatorEnd - 1); |
| | | 2100 | | } |
| | | 2101 | | } |
| | | 2102 | | } |
| | | 2103 | | |
| | 0 | 2104 | | return string.Empty; |
| | | 2105 | | } |
| | | 2106 | | |
| | | 2107 | | private static int IndexOfTimePart(string format, int startIndex, string timeParts) |
| | | 2108 | | { |
| | 0 | 2109 | | Debug.Assert(startIndex >= 0, "startIndex cannot be negative"); |
| | 0 | 2110 | | Debug.Assert(!timeParts.AsSpan().ContainsAny('\'', '\\'), "timeParts cannot include quote characters"); |
| | 0 | 2111 | | bool inQuote = false; |
| | 0 | 2112 | | for (int i = startIndex; i < format.Length; ++i) |
| | | 2113 | | { |
| | | 2114 | | // See if we have a time Part |
| | 0 | 2115 | | if (!inQuote && timeParts.Contains(format[i])) |
| | | 2116 | | { |
| | 0 | 2117 | | return i; |
| | | 2118 | | } |
| | 0 | 2119 | | switch (format[i]) |
| | | 2120 | | { |
| | | 2121 | | case '\\': |
| | 0 | 2122 | | if (i + 1 < format.Length) |
| | | 2123 | | { |
| | 0 | 2124 | | ++i; |
| | 0 | 2125 | | switch (format[i]) |
| | | 2126 | | { |
| | | 2127 | | case '\'': |
| | | 2128 | | case '\\': |
| | | 2129 | | break; |
| | | 2130 | | default: |
| | 0 | 2131 | | --i; // backup since we will move over this next |
| | 0 | 2132 | | break; |
| | | 2133 | | } |
| | | 2134 | | } |
| | | 2135 | | break; |
| | | 2136 | | case '\'': |
| | 0 | 2137 | | inQuote = !inQuote; |
| | | 2138 | | break; |
| | | 2139 | | } |
| | | 2140 | | } |
| | | 2141 | | |
| | 0 | 2142 | | return -1; |
| | | 2143 | | } |
| | | 2144 | | |
| | | 2145 | | internal static bool IsCustomCultureId(int cultureId) |
| | | 2146 | | { |
| | 0 | 2147 | | return cultureId == CultureInfo.LOCALE_CUSTOM_DEFAULT || cultureId == CultureInfo.LOCALE_CUSTOM_UNSPECIFIED; |
| | | 2148 | | } |
| | | 2149 | | |
| | | 2150 | | private string[] GetNativeDigits() |
| | | 2151 | | { |
| | 0 | 2152 | | string[] result = NumberFormatInfo.s_asciiDigits; |
| | | 2153 | | |
| | | 2154 | | // NLS LOCALE_SNATIVEDIGITS (array of 10 single character strings). In case of ICU, the buffer can be longer |
| | 0 | 2155 | | string digits = GetLocaleInfoCoreUserOverride(LocaleStringData.Digits); |
| | | 2156 | | |
| | | 2157 | | // if digits.Length < NumberFormatInfo.s_asciiDigits.Length means the native digits setting is messed up in |
| | | 2158 | | // Instead of throwing IndexOutOfRangeException that will be hard to diagnose after the fact, we'll fall bac |
| | 0 | 2159 | | if (digits.Length < NumberFormatInfo.s_asciiDigits.Length) |
| | | 2160 | | { |
| | 0 | 2161 | | return result; |
| | | 2162 | | } |
| | | 2163 | | |
| | | 2164 | | // In ICU we separate the digits with the '\uFFFF' character |
| | | 2165 | | |
| | 0 | 2166 | | if (digits.StartsWith("0\uFFFF1\uFFFF2\uFFFF3\uFFFF4\uFFFF5\uFFFF6\uFFFF7\uFFFF8\uFFFF9\uFFFF", StringCompar |
| | 0 | 2167 | | digits.StartsWith("0123456789", StringComparison.Ordinal)) // NLS common cases |
| | | 2168 | | { |
| | 0 | 2169 | | return result; |
| | | 2170 | | } |
| | | 2171 | | |
| | | 2172 | | // Non-ASCII digits |
| | | 2173 | | |
| | | 2174 | | // Check if values coming from ICU separated by 0xFFFF |
| | 0 | 2175 | | int ffffPos = digits.IndexOf('\uFFFF'); |
| | | 2176 | | |
| | 0 | 2177 | | result = new string[10]; |
| | 0 | 2178 | | if (ffffPos < 0) // NLS case |
| | | 2179 | | { |
| | 0 | 2180 | | for (int i = 0; i < result.Length; i++) |
| | | 2181 | | { |
| | 0 | 2182 | | result[i] = char.ToString(digits[i]); |
| | | 2183 | | } |
| | | 2184 | | |
| | 0 | 2185 | | return result; |
| | | 2186 | | } |
| | | 2187 | | |
| | | 2188 | | // ICU case |
| | | 2189 | | |
| | 0 | 2190 | | int start = 0; |
| | 0 | 2191 | | int index = 0; |
| | | 2192 | | |
| | | 2193 | | do |
| | | 2194 | | { |
| | 0 | 2195 | | result[index++] = digits.Substring(start, ffffPos - start); |
| | 0 | 2196 | | start = ++ffffPos; |
| | 0 | 2197 | | while ((uint)ffffPos < (uint)digits.Length && digits[ffffPos] != '\uFFFF') |
| | | 2198 | | { |
| | 0 | 2199 | | ffffPos++; |
| | | 2200 | | } |
| | | 2201 | | |
| | 0 | 2202 | | } while (ffffPos < digits.Length && index < 10); |
| | | 2203 | | |
| | 0 | 2204 | | Debug.Assert(index >= 10, $"Couldn't read native digits for '{_sWindowsName}' successfully."); |
| | | 2205 | | |
| | 0 | 2206 | | return index < 10 ? NumberFormatInfo.s_asciiDigits : result; |
| | | 2207 | | } |
| | | 2208 | | |
| | | 2209 | | internal void GetNFIValues(NumberFormatInfo nfi) |
| | | 2210 | | { |
| | 0 | 2211 | | if (GlobalizationMode.InvariantNoLoad || IsInvariantCulture) |
| | | 2212 | | { |
| | 0 | 2213 | | nfi._positiveSign = _sPositiveSign!; |
| | 0 | 2214 | | nfi._negativeSign = _sNegativeSign!; |
| | | 2215 | | |
| | 0 | 2216 | | nfi._numberGroupSeparator = _sThousandSeparator!; |
| | 0 | 2217 | | nfi._numberDecimalSeparator = _sDecimalSeparator!; |
| | 0 | 2218 | | nfi._numberDecimalDigits = _iDigits; |
| | 0 | 2219 | | nfi._numberNegativePattern = _iNegativeNumber; |
| | | 2220 | | |
| | 0 | 2221 | | nfi._currencySymbol = _sCurrency!; |
| | 0 | 2222 | | nfi._currencyGroupSeparator = _sMonetaryThousand!; |
| | 0 | 2223 | | nfi._currencyDecimalSeparator = _sMonetaryDecimal!; |
| | 0 | 2224 | | nfi._currencyDecimalDigits = _iCurrencyDigits; |
| | 0 | 2225 | | nfi._currencyNegativePattern = _iNegativeCurrency; |
| | 0 | 2226 | | nfi._currencyPositivePattern = _iCurrency; |
| | | 2227 | | } |
| | | 2228 | | else |
| | | 2229 | | { |
| | 0 | 2230 | | Debug.Assert(_sWindowsName != null, "[CultureData.GetNFIValues] Expected _sWindowsName to be populated b |
| | | 2231 | | // String values |
| | 0 | 2232 | | nfi._positiveSign = GetLocaleInfoCoreUserOverride(LocaleStringData.PositiveSign); |
| | 0 | 2233 | | nfi._negativeSign = GetLocaleInfoCoreUserOverride(LocaleStringData.NegativeSign); |
| | | 2234 | | |
| | 0 | 2235 | | nfi._numberDecimalSeparator = GetLocaleInfoCoreUserOverride(LocaleStringData.DecimalSeparator); |
| | 0 | 2236 | | nfi._numberGroupSeparator = GetLocaleInfoCoreUserOverride(LocaleStringData.ThousandSeparator); |
| | 0 | 2237 | | nfi._currencyGroupSeparator = GetLocaleInfoCoreUserOverride(LocaleStringData.MonetaryThousandSeparator); |
| | 0 | 2238 | | nfi._currencyDecimalSeparator = GetLocaleInfoCoreUserOverride(LocaleStringData.MonetaryDecimalSeparator) |
| | 0 | 2239 | | nfi._currencySymbol = GetLocaleInfoCoreUserOverride(LocaleStringData.MonetarySymbol); |
| | | 2240 | | |
| | | 2241 | | // Numeric values |
| | 0 | 2242 | | nfi._numberDecimalDigits = GetLocaleInfoCoreUserOverride(LocaleNumberData.FractionalDigitsCount); |
| | 0 | 2243 | | nfi._currencyDecimalDigits = GetLocaleInfoCoreUserOverride(LocaleNumberData.MonetaryFractionalDigitsCoun |
| | 0 | 2244 | | nfi._currencyPositivePattern = GetLocaleInfoCoreUserOverride(LocaleNumberData.PositiveMonetaryNumberForm |
| | 0 | 2245 | | nfi._currencyNegativePattern = GetLocaleInfoCoreUserOverride(LocaleNumberData.NegativeMonetaryNumberForm |
| | 0 | 2246 | | nfi._numberNegativePattern = GetLocaleInfoCoreUserOverride(LocaleNumberData.NegativeNumberFormat); |
| | | 2247 | | |
| | 0 | 2248 | | nfi._nativeDigits = GetNativeDigits(); |
| | | 2249 | | |
| | 0 | 2250 | | Debug.Assert(_sRealName != null); |
| | 0 | 2251 | | nfi._digitSubstitution = ShouldUseUserOverrideNlsData ? NlsGetLocaleInfo(LocaleNumberData.DigitSubstitut |
| | | 2252 | | } |
| | | 2253 | | |
| | | 2254 | | // Gather additional data |
| | 0 | 2255 | | nfi._numberGroupSizes = NumberGroupSizes; |
| | 0 | 2256 | | nfi._currencyGroupSizes = CurrencyGroupSizes; |
| | | 2257 | | |
| | | 2258 | | // prefer the cached value since these do not have user overrides |
| | 0 | 2259 | | nfi._percentNegativePattern = PercentNegativePattern; |
| | 0 | 2260 | | nfi._percentPositivePattern = PercentPositivePattern; |
| | 0 | 2261 | | nfi._percentSymbol = PercentSymbol; |
| | 0 | 2262 | | nfi._perMilleSymbol = PerMilleSymbol; |
| | | 2263 | | |
| | 0 | 2264 | | nfi._negativeInfinitySymbol = NegativeInfinitySymbol; |
| | 0 | 2265 | | nfi._positiveInfinitySymbol = PositiveInfinitySymbol; |
| | 0 | 2266 | | nfi._nanSymbol = NaNSymbol; |
| | | 2267 | | |
| | | 2268 | | // We don't have percent values, so use the number values |
| | 0 | 2269 | | nfi._percentDecimalDigits = nfi._numberDecimalDigits; |
| | 0 | 2270 | | nfi._percentDecimalSeparator = nfi._numberDecimalSeparator; |
| | 0 | 2271 | | nfi._percentGroupSizes = nfi._numberGroupSizes; |
| | 0 | 2272 | | nfi._percentGroupSeparator = nfi._numberGroupSeparator; |
| | | 2273 | | |
| | | 2274 | | // Clean up a few odd values |
| | | 2275 | | |
| | | 2276 | | // Windows usually returns an empty positive sign, but we like it to be "+" |
| | 0 | 2277 | | if (string.IsNullOrEmpty(nfi._positiveSign)) |
| | | 2278 | | { |
| | 0 | 2279 | | nfi._positiveSign = "+"; |
| | | 2280 | | } |
| | | 2281 | | |
| | | 2282 | | // Special case for Italian. The currency decimal separator in the control panel is the empty string. When |
| | | 2283 | | // specifies C4 as the currency format, this results in the number apparently getting multiplied by 10000 be |
| | | 2284 | | // decimal point doesn't show up. We'll just hack this here because our default currency format will never |
| | 0 | 2285 | | if (string.IsNullOrEmpty(nfi._currencyDecimalSeparator)) |
| | | 2286 | | { |
| | 0 | 2287 | | nfi._currencyDecimalSeparator = nfi._numberDecimalSeparator; |
| | | 2288 | | } |
| | 0 | 2289 | | } |
| | | 2290 | | |
| | | 2291 | | /// <remarks> |
| | | 2292 | | /// This is ONLY used for caching names and shouldn't be used for anything else |
| | | 2293 | | /// </remarks> |
| | 0 | 2294 | | internal static string AnsiToLower(string testString) => TextInfo.ToLowerAsciiInvariant(testString); |
| | | 2295 | | |
| | | 2296 | | private int GetLocaleInfoCore(LocaleNumberData type) |
| | | 2297 | | { |
| | | 2298 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2299 | | if (GlobalizationMode.Invariant) |
| | 0 | 2300 | | return 0; |
| | | 2301 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2302 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(type) : IcuGetLocaleInfo(type); |
| | | 2303 | | #else |
| | 0 | 2304 | | return GlobalizationMode.UseNls ? NlsGetLocaleInfo(type) : IcuGetLocaleInfo(type); |
| | | 2305 | | #endif |
| | | 2306 | | } |
| | | 2307 | | |
| | | 2308 | | private int GetLocaleInfoCoreUserOverride(LocaleNumberData type) |
| | | 2309 | | { |
| | | 2310 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2311 | | if (GlobalizationMode.Invariant) |
| | 0 | 2312 | | return 0; |
| | | 2313 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2314 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(type) : IcuGetLocaleInfo(type); |
| | | 2315 | | #else |
| | 0 | 2316 | | return ShouldUseUserOverrideNlsData ? NlsGetLocaleInfo(type) : IcuGetLocaleInfo(type); |
| | | 2317 | | #endif |
| | | 2318 | | } |
| | | 2319 | | |
| | | 2320 | | private string GetLocaleInfoCoreUserOverride(LocaleStringData type) |
| | | 2321 | | { |
| | | 2322 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2323 | | if (GlobalizationMode.Invariant) |
| | 0 | 2324 | | return null!; |
| | | 2325 | | |
| | | 2326 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2327 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(type) : IcuGetLocaleInfo(type); |
| | | 2328 | | #else |
| | 0 | 2329 | | return ShouldUseUserOverrideNlsData ? NlsGetLocaleInfo(type) : IcuGetLocaleInfo(type); |
| | | 2330 | | #endif |
| | | 2331 | | } |
| | | 2332 | | |
| | | 2333 | | private string GetLocaleInfoCore(LocaleStringData type, string? uiCultureName = null) |
| | | 2334 | | { |
| | | 2335 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2336 | | if (GlobalizationMode.Invariant) |
| | 0 | 2337 | | return null!; |
| | | 2338 | | |
| | | 2339 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2340 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(type, uiCultureName) : IcuGetLocaleInfo(type, uiCultur |
| | | 2341 | | #else |
| | 0 | 2342 | | return GlobalizationMode.UseNls ? NlsGetLocaleInfo(type) : IcuGetLocaleInfo(type, uiCultureName); |
| | | 2343 | | #endif |
| | | 2344 | | } |
| | | 2345 | | |
| | | 2346 | | private string GetLocaleInfoCore(string localeName, LocaleStringData type, string? uiCultureName = null) |
| | | 2347 | | { |
| | | 2348 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2349 | | if (GlobalizationMode.Invariant) |
| | 0 | 2350 | | return null!; |
| | | 2351 | | |
| | | 2352 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2353 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(localeName, type, uiCultureName) : IcuGetLocaleInfo(lo |
| | | 2354 | | #else |
| | 0 | 2355 | | return GlobalizationMode.UseNls ? NlsGetLocaleInfo(localeName, type) : IcuGetLocaleInfo(localeName, type, ui |
| | | 2356 | | #endif |
| | | 2357 | | } |
| | | 2358 | | |
| | | 2359 | | private int[] GetLocaleInfoCoreUserOverride(LocaleGroupingData type) |
| | | 2360 | | { |
| | | 2361 | | // This is never reached but helps illinker statically remove dependencies |
| | 0 | 2362 | | if (GlobalizationMode.Invariant) |
| | 0 | 2363 | | return null!; |
| | | 2364 | | |
| | | 2365 | | #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS |
| | | 2366 | | return GlobalizationMode.Hybrid ? GetLocaleInfoNative(type) : IcuGetLocaleInfo(type); |
| | | 2367 | | #else |
| | 0 | 2368 | | return ShouldUseUserOverrideNlsData ? NlsGetLocaleInfo(type) : IcuGetLocaleInfo(type); |
| | | 2369 | | #endif |
| | | 2370 | | } |
| | | 2371 | | |
| | | 2372 | | /// <remarks> |
| | | 2373 | | /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementa |
| | | 2374 | | /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to L |
| | | 2375 | | /// </remarks> |
| | | 2376 | | private enum LocaleStringData : uint |
| | | 2377 | | { |
| | | 2378 | | /// <summary>localized name of locale, eg "German (Germany)" in UI language (corresponds to LOCALE_SLOCALIZE |
| | | 2379 | | LocalizedDisplayName = 0x00000002, |
| | | 2380 | | /// <summary>Display name (language + country usually) in English, eg "German (Germany)" (corresponds to LOC |
| | | 2381 | | EnglishDisplayName = 0x00000072, |
| | | 2382 | | /// <summary>Display name in native locale language, eg "Deutsch (Deutschland) (corresponds to LOCALE_SNATIV |
| | | 2383 | | NativeDisplayName = 0x00000073, |
| | | 2384 | | /// <summary>Language Display Name for a language, eg "German" in UI language (corresponds to LOCALE_SLOCALI |
| | | 2385 | | LocalizedLanguageName = 0x0000006f, |
| | | 2386 | | /// <summary>English name of language, eg "German" (corresponds to LOCALE_SENGLISHLANGUAGENAME)</summary> |
| | | 2387 | | EnglishLanguageName = 0x00001001, |
| | | 2388 | | /// <summary>native name of language, eg "Deutsch" (corresponds to LOCALE_SNATIVELANGUAGENAME)</summary> |
| | | 2389 | | NativeLanguageName = 0x00000004, |
| | | 2390 | | /// <summary>localized name of country, eg "Germany" in UI language (corresponds to LOCALE_SLOCALIZEDCOUNTRY |
| | | 2391 | | LocalizedCountryName = 0x00000006, |
| | | 2392 | | /// <summary>English name of country, eg "Germany" (corresponds to LOCALE_SENGLISHCOUNTRYNAME)</summary> |
| | | 2393 | | EnglishCountryName = 0x00001002, |
| | | 2394 | | /// <summary>native name of country, eg "Deutschland" (corresponds to LOCALE_SNATIVECOUNTRYNAME)</summary> |
| | | 2395 | | NativeCountryName = 0x00000008, |
| | | 2396 | | /// <summary>abbreviated language name (corresponds to LOCALE_SABBREVLANGNAME)</summary> |
| | | 2397 | | AbbreviatedWindowsLanguageName = 0x00000003, |
| | | 2398 | | /// <summary>list item separator (corresponds to LOCALE_SLIST)</summary> |
| | | 2399 | | ListSeparator = 0x0000000C, |
| | | 2400 | | /// <summary>decimal separator (corresponds to LOCALE_SDECIMAL)</summary> |
| | | 2401 | | DecimalSeparator = 0x0000000E, |
| | | 2402 | | /// <summary>thousand separator (corresponds to LOCALE_STHOUSAND)</summary> |
| | | 2403 | | ThousandSeparator = 0x0000000F, |
| | | 2404 | | /// <summary>native digits for 0-9, eg "0123456789" (corresponds to LOCALE_SNATIVEDIGITS)</summary> |
| | | 2405 | | Digits = 0x00000013, |
| | | 2406 | | /// <summary>local monetary symbol (corresponds to LOCALE_SCURRENCY)</summary> |
| | | 2407 | | MonetarySymbol = 0x00000014, |
| | | 2408 | | /// <summary>English currency name (corresponds to LOCALE_SENGCURRNAME)</summary> |
| | | 2409 | | CurrencyEnglishName = 0x00001007, |
| | | 2410 | | /// <summary>Native currency name (corresponds to LOCALE_SNATIVECURRNAME)</summary> |
| | | 2411 | | CurrencyNativeName = 0x00001008, |
| | | 2412 | | /// <summary>uintl monetary symbol (corresponds to LOCALE_SINTLSYMBOL)</summary> |
| | | 2413 | | Iso4217MonetarySymbol = 0x00000015, |
| | | 2414 | | /// <summary>monetary decimal separator (corresponds to LOCALE_SMONDECIMALSEP)</summary> |
| | | 2415 | | MonetaryDecimalSeparator = 0x00000016, |
| | | 2416 | | /// <summary>monetary thousand separator (corresponds to LOCALE_SMONTHOUSANDSEP)</summary> |
| | | 2417 | | MonetaryThousandSeparator = 0x00000017, |
| | | 2418 | | /// <summary>AM designator (corresponds to LOCALE_S1159)</summary> |
| | | 2419 | | AMDesignator = 0x00000028, |
| | | 2420 | | /// <summary>PM designator (corresponds to LOCALE_S2359)</summary> |
| | | 2421 | | PMDesignator = 0x00000029, |
| | | 2422 | | /// <summary>positive sign (corresponds to LOCALE_SPOSITIVESIGN)</summary> |
| | | 2423 | | PositiveSign = 0x00000050, |
| | | 2424 | | /// <summary>negative sign (corresponds to LOCALE_SNEGATIVESIGN)</summary> |
| | | 2425 | | NegativeSign = 0x00000051, |
| | | 2426 | | /// <summary>ISO abbreviated language name (corresponds to LOCALE_SISO639LANGNAME)</summary> |
| | | 2427 | | Iso639LanguageTwoLetterName = 0x00000059, |
| | | 2428 | | /// <summary>ISO abbreviated country name (corresponds to LOCALE_SISO639LANGNAME2)</summary> |
| | | 2429 | | Iso639LanguageThreeLetterName = 0x00000067, |
| | | 2430 | | /// <summary>ISO abbreviated language name (corresponds to LOCALE_SISO639LANGNAME)</summary> |
| | | 2431 | | Iso639LanguageName = 0x00000059, |
| | | 2432 | | /// <summary>ISO abbreviated country name (corresponds to LOCALE_SISO3166CTRYNAME)</summary> |
| | | 2433 | | Iso3166CountryName = 0x0000005A, |
| | | 2434 | | /// <summary>3 letter ISO country code (corresponds to LOCALE_SISO3166CTRYNAME2)</summary> |
| | | 2435 | | Iso3166CountryName2 = 0x00000068, // 3 character ISO country name |
| | | 2436 | | /// <summary>Not a Number (corresponds to LOCALE_SNAN)</summary> |
| | | 2437 | | NaNSymbol = 0x00000069, |
| | | 2438 | | /// <summary>+ Infinity (corresponds to LOCALE_SPOSINFINITY)</summary> |
| | | 2439 | | PositiveInfinitySymbol = 0x0000006a, |
| | | 2440 | | /// <summary>- Infinity (corresponds to LOCALE_SNEGINFINITY)</summary> |
| | | 2441 | | NegativeInfinitySymbol = 0x0000006b, |
| | | 2442 | | /// <summary>Fallback name for resources (corresponds to LOCALE_SPARENT)</summary> |
| | | 2443 | | ParentName = 0x0000006d, |
| | | 2444 | | /// <summary>Fallback name for within the console (corresponds to LOCALE_SCONSOLEFALLBACKNAME)</summary> |
| | | 2445 | | ConsoleFallbackName = 0x0000006e, |
| | | 2446 | | /// <summary>Returns the percent symbol (corresponds to LOCALE_SPERCENT)</summary> |
| | | 2447 | | PercentSymbol = 0x00000076, |
| | | 2448 | | /// <summary>Returns the permille (U+2030) symbol (corresponds to LOCALE_SPERMILLE)</summary> |
| | | 2449 | | PerMilleSymbol = 0x00000077 |
| | | 2450 | | } |
| | | 2451 | | |
| | | 2452 | | /// <remarks> |
| | | 2453 | | /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementa |
| | | 2454 | | /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to L |
| | | 2455 | | /// </remarks> |
| | | 2456 | | private enum LocaleGroupingData : uint |
| | | 2457 | | { |
| | | 2458 | | /// <summary>digit grouping (corresponds to LOCALE_SGROUPING)</summary> |
| | | 2459 | | Digit = 0x00000010, |
| | | 2460 | | /// <summary>monetary grouping (corresponds to LOCALE_SMONGROUPING)</summary> |
| | | 2461 | | Monetary = 0x00000018, |
| | | 2462 | | } |
| | | 2463 | | |
| | | 2464 | | /// <remarks> |
| | | 2465 | | /// The numeric values of the enum members match their Win32 counterparts. The CultureData Win32 PAL implementa |
| | | 2466 | | /// takes a dependency on this fact, in order to prevent having to construct a mapping from internal values to L |
| | | 2467 | | /// </remarks> |
| | | 2468 | | private enum LocaleNumberData : uint |
| | | 2469 | | { |
| | | 2470 | | /// <summary>language id (corresponds to LOCALE_ILANGUAGE)</summary> |
| | | 2471 | | LanguageId = 0x00000001, |
| | | 2472 | | /// <summary>geographical location id, (corresponds to LOCALE_IGEOID)</summary> |
| | | 2473 | | GeoId = 0x0000005B, |
| | | 2474 | | /// <summary>0 = context, 1 = none, 2 = national (corresponds to LOCALE_IDIGITSUBSTITUTION)</summary> |
| | | 2475 | | DigitSubstitution = 0x00001014, |
| | | 2476 | | /// <summary>0 = metric, 1 = US (corresponds to LOCALE_IMEASURE)</summary> |
| | | 2477 | | MeasurementSystem = 0x0000000D, |
| | | 2478 | | /// <summary>number of fractional digits (corresponds to LOCALE_IDIGITS)</summary> |
| | | 2479 | | FractionalDigitsCount = 0x00000011, |
| | | 2480 | | /// <summary>negative number mode (corresponds to LOCALE_INEGNUMBER)</summary> |
| | | 2481 | | NegativeNumberFormat = 0x00001010, |
| | | 2482 | | /// <summary># local monetary digits (corresponds to LOCALE_ICURRDIGITS)</summary> |
| | | 2483 | | MonetaryFractionalDigitsCount = 0x00000019, |
| | | 2484 | | /// <summary>positive currency mode (corresponds to LOCALE_ICURRENCY)</summary> |
| | | 2485 | | PositiveMonetaryNumberFormat = 0x0000001B, |
| | | 2486 | | /// <summary>negative currency mode (corresponds to LOCALE_INEGCURR)</summary> |
| | | 2487 | | NegativeMonetaryNumberFormat = 0x0000001C, |
| | | 2488 | | /// <summary>type of calendar specifier (corresponds to LOCALE_ICALENDARTYPE)</summary> |
| | | 2489 | | CalendarType = 0x00001009, |
| | | 2490 | | /// <summary>first day of week specifier (corresponds to LOCALE_IFIRSTDAYOFWEEK)</summary> |
| | | 2491 | | FirstDayOfWeek = 0x0000100C, |
| | | 2492 | | /// <summary>first week of year specifier (corresponds to LOCALE_IFIRSTWEEKOFYEAR)</summary> |
| | | 2493 | | FirstWeekOfYear = 0x0000100D, |
| | | 2494 | | /// <summary> |
| | | 2495 | | /// Returns one of the following 4 reading layout values: |
| | | 2496 | | /// 0 - Left to right (eg en-US) |
| | | 2497 | | /// 1 - Right to left (eg arabic locales) |
| | | 2498 | | /// 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) |
| | | 2499 | | /// 3 - Vertical top to bottom with columns proceeding to the right |
| | | 2500 | | /// (corresponds to LOCALE_IREADINGLAYOUT) |
| | | 2501 | | /// </summary> |
| | | 2502 | | ReadingLayout = 0x00000070, |
| | | 2503 | | /// <summary>Returns 0-11 for the negative percent format (corresponds to LOCALE_INEGATIVEPERCENT)</summary> |
| | | 2504 | | NegativePercentFormat = 0x00000074, |
| | | 2505 | | /// <summary>Returns 0-3 for the positive percent format (corresponds to LOCALE_IPOSITIVEPERCENT)</summary> |
| | | 2506 | | PositivePercentFormat = 0x00000075, |
| | | 2507 | | /// <summary>default ansi code page (corresponds to LOCALE_IDEFAULTCODEPAGE)</summary> |
| | | 2508 | | OemCodePage = 0x0000000B, |
| | | 2509 | | /// <summary>default ansi code page (corresponds to LOCALE_IDEFAULTANSICODEPAGE)</summary> |
| | | 2510 | | AnsiCodePage = 0x00001004, |
| | | 2511 | | /// <summary>default mac code page (corresponds to LOCALE_IDEFAULTMACCODEPAGE)</summary> |
| | | 2512 | | MacCodePage = 0x00001011, |
| | | 2513 | | /// <summary>default ebcdic code page (corresponds to LOCALE_IDEFAULTEBCDICCODEPAGE)</summary> |
| | | 2514 | | EbcdicCodePage = 0x00001012, |
| | | 2515 | | } |
| | | 2516 | | } |
| | | 2517 | | } |
| | | 2518 | | |