1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2009-2013, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 package com.ibm.icu.impl; 10 11 import java.util.MissingResourceException; 12 13 14 /** 15 * Utilities for mapping between old and new language, country, and other 16 * locale ID related names. 17 */ 18 public class LocaleIDs { 19 20 /** 21 * Returns a list of all 2-letter country codes defined in ISO 3166. 22 * Can be used to create Locales. 23 * @stable ICU 3.0 24 */ getISOCountries()25 public static String[] getISOCountries() { 26 return _countries.clone(); 27 } 28 29 /** 30 * Returns a list of all 2-letter language codes defined in ISO 639 31 * plus additional 3-letter codes determined to be useful for locale generation as 32 * defined by Unicode CLDR. 33 * Can be used to create Locales. 34 * [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. 35 * The list this function returns includes both the new and the old codes for the 36 * languages whose codes have changed.] 37 * @stable ICU 3.0 38 */ getISOLanguages()39 public static String[] getISOLanguages() { 40 return _languages.clone(); 41 } 42 43 /** 44 * Returns a three-letter abbreviation for the provided country. If the provided 45 * country is empty, returns the empty string. Otherwise, returns 46 * an uppercase ISO 3166 3-letter country code. 47 * @exception MissingResourceException Throws MissingResourceException if the 48 * three-letter country abbreviation is not available for this locale. 49 * @stable ICU 3.0 50 */ getISO3Country(String country)51 public static String getISO3Country(String country){ 52 53 int offset = findIndex(_countries, country); 54 if(offset>=0){ 55 return _countries3[offset]; 56 }else{ 57 offset = findIndex(_obsoleteCountries, country); 58 if(offset>=0){ 59 return _obsoleteCountries3[offset]; 60 } 61 } 62 return ""; 63 } 64 /** 65 * Returns a three-letter abbreviation for the language. If language is 66 * empty, returns the empty string. Otherwise, returns 67 * a lowercase ISO 639-2/T language code. 68 * The ISO 639-2 language codes can be found on-line at 69 * <a href="ftp://dkuug.dk/i18n/iso-639-2.txt"><code>ftp://dkuug.dk/i18n/iso-639-2.txt</code></a> 70 * @exception MissingResourceException Throws MissingResourceException if the 71 * three-letter language abbreviation is not available for this locale. 72 * @stable ICU 3.0 73 */ getISO3Language(String language)74 public static String getISO3Language(String language) { 75 76 int offset = findIndex(_languages, language); 77 if(offset>=0){ 78 return _languages3[offset]; 79 } else { 80 offset = findIndex(_obsoleteLanguages, language); 81 if (offset >= 0) { 82 return _obsoleteLanguages3[offset]; 83 } 84 } 85 return ""; 86 } 87 threeToTwoLetterLanguage(String lang)88 public static String threeToTwoLetterLanguage(String lang) { 89 90 /* convert 3 character code to 2 character code if possible *CWB*/ 91 int offset = findIndex(_languages3, lang); 92 if (offset >= 0) { 93 return _languages[offset]; 94 } 95 96 offset = findIndex(_obsoleteLanguages3, lang); 97 if (offset >= 0) { 98 return _obsoleteLanguages[offset]; 99 } 100 101 return null; 102 } 103 threeToTwoLetterRegion(String region)104 public static String threeToTwoLetterRegion(String region) { 105 106 /* convert 3 character code to 2 character code if possible *CWB*/ 107 int offset = findIndex(_countries3, region); 108 if (offset >= 0) { 109 return _countries[offset]; 110 } 111 112 offset = findIndex(_obsoleteCountries3, region); 113 if (offset >= 0) { 114 return _obsoleteCountries[offset]; 115 } 116 117 return null; 118 } 119 120 /** 121 * linear search of the string array. the arrays are unfortunately ordered by the 122 * two-letter target code, not the three-letter search code, which seems backwards. 123 */ findIndex(String[] array, String target)124 private static int findIndex(String[] array, String target){ 125 for (int i = 0; i < array.length; i++) { 126 if (target.equals(array[i])) { 127 return i; 128 } 129 } 130 return -1; 131 } 132 133 134 /** 135 * Tables used in normalizing portions of the id. 136 */ 137 /* tables updated per http://lcweb.loc.gov/standards/iso639-2/ 138 to include the revisions up to 2001/7/27 *CWB*/ 139 /* Subsequent hand addition of selected languages */ 140 /* The 3 character codes are the terminology codes like RFC 3066. 141 This is compatible with prior ICU codes */ 142 /* "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in 143 the table but now at the end of the table because 144 3 character codes are duplicates. This avoids bad searches 145 going from 3 to 2 character codes.*/ 146 /* The range qaa-qtz is reserved for local use. */ 147 148 /* This list MUST be in sorted order, and MUST contain the two-letter codes 149 if one exists otherwise use the three letter code */ 150 private static final String[] _languages = { 151 "aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb", 152 "af", "afh", "agq", "ain", "ak", "akk", "akz", "ale", 153 "aln", "alt", "am", "an", "ang", "anp", "ar", "arc", 154 "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "as", 155 "asa", "ase", "ast", "av", "avk", "awa", "ay", "az", 156 "ba", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", 157 "be", "bej", "bem", "bew", "bez", "bfd", "bfq", "bg", 158 "bgc", "bgn", "bho", "bi", "bik", "bin", "bjn", "bkm", "bla", 159 "bm", "bn", "bo", "bpy", "bqi", "br", "bra", "brh", 160 "brx", "bs", "bss", "bua", "bug", "bum", "byn", "byv", 161 "ca", "cad", "car", "cay", "cch", "ccp", "ce", "ceb", "cgg", 162 "ch", "chb", "chg", "chk", "chm", "chn", "cho", "chp", 163 "chr", "chy", "ckb", "co", "cop", "cps", "cr", "crh", 164 "cs", "csb", "cu", "cv", "cy", 165 "da", "dak", "dar", "dav", "day", "de", "del", "den", 166 "dgr", "din", "dje", "doi", "dra", "dsb", "dua", "dum", 167 "dv", "dyo", "dyu", "dz", "dzg", 168 "ebu", "ee", "efi", "egy", "eka", "el", "elx", "en", 169 "enm", "eo", "es", "et", "eu", "ewo", 170 "fa", "fan", "fat", "ff", "fi", "fil", "fiu", "fj", 171 "fo", "fon", "fr", "frm", "fro", "frr", "frs", "fur", 172 "fy", 173 "ga", "gaa", "gay", "gba", "gd", "gem", "gez", "gil", 174 "gl", "gmh", "gn", "goh", "gon", "gor", "got", "grb", 175 "grc", "gsw", "gu", "guz", "gv", "gwi", 176 "ha", "hai", "haw", "he", "hi", "hil", "him", "hit", 177 "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", 178 "hz", 179 "ia", "iba", "ibb", "id", "ie", "ig", "ii", "ijo", 180 "ik", "ilo", "inc", "ine", "inh", "io", "ira", "iro", 181 "is", "it", "iu", 182 "ja", "jbo", "jgo", "jmc", "jpr", "jrb", "jv", 183 "ka", "kaa", "kab", "kac", "kaj", "kam", "kar", "kaw", 184 "kbd", "kbl", "kcg", "kde", "kea", "kfo", "kg", "kha", 185 "khi", "kho", "khq", "ki", "kj", "kk", "kkj", "kl", 186 "kln", "km", "kmb", "kn", "ko", "kok", "kos", "kpe", 187 "kr", "krc", "krl", "kro", "kru", "ks", "ksb", "ksf", 188 "ksh", "ku", "kum", "kut", "kv", "kw", "ky", 189 "la", "lad", "lag", "lah", "lam", "lb", "lez", "lg", 190 "li", "lkt", "ln", "lo", "lol", "loz", "lt", "lu", 191 "lua", "lui", "lun", "luo", "lus", "luy", "lv", 192 "mad", "maf", "mag", "mai", "mak", "man", "map", "mas", 193 "mde", "mdf", "mdr", "men", "mer", "mfe", "mg", "mga", 194 "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", 195 "mkh", "ml", "mn", "mnc", "mni", "mno", "moh", 196 "mos", "mr", "ms", "mt", "mua", "mul", "mun", "mus", 197 "mwl", "mwr", "my", "mye", "myn", "myv", 198 "na", "nah", "nai", "nap", "naq", "nb", "nd", "nds", 199 "ne", "new", "ng", "nia", "nic", "niu", "nl", "nmg", 200 "nn", "nnh", "no", "nog", "non", "nqo", "nr", "nso", 201 "nub", "nus", "nv", "nwc", "ny", "nym", "nyn", "nyo", 202 "nzi", 203 "oc", "oj", "om", "or", "os", "osa", "ota", "oto", 204 "pa", "paa", "pag", "pal", "pam", "pap", "pau", "peo", 205 "phi", "phn", "pi", "pl", "pon", "pra", "pro", "ps", 206 "pt", 207 "qu", 208 "raj", "rap", "rar", "rm", "rn", "ro", "roa", "rof", 209 "rom", "ru", "rup", "rw", "rwk", 210 "sa", "sad", "sah", "sai", "sal", "sam", "saq", "sas", 211 "sat", "sba", "sbp", "sc", "scn", "sco", "sd", "se", 212 "see", "seh", "sel", "sem", "ses", "sg", "sga", "sgn", 213 "shi", "shn", "shu", "si", "sid", "sio", "sit", 214 "sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn", 215 "sms", "sn", "snk", "so", "sog", "son", "sq", "sr", 216 "srn", "srr", "ss", "ssa", "ssy", "st", "su", "suk", 217 "sus", "sux", "sv", "sw", "swb", "syc", "syr", 218 "ta", "tai", "te", "tem", "teo", "ter", "tet", "tg", 219 "th", "ti", "tig", "tiv", "tk", "tkl", "tlh", 220 "tli", "tmh", "tn", "to", "tog", "tpi", "tr", "trv", 221 "ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw", 222 "twq", "ty", "tyv", "tzm", 223 "udm", "ug", "uga", "uk", "umb", "und", "ur", "uz", 224 "vai", "ve", "vi", "vo", "vot", "vun", 225 "wa", "wae", "wak", "wal", "war", "was", "wen", "wo", 226 "xal", "xh", "xog", 227 "yao", "yap", "yav", "ybb", "yi", "yo", "ypk", "yue", 228 "za", "zap", "zbl", "zen", "zh", "znd", "zu", "zun", 229 "zxx", "zza" }; 230 231 private static final String[] _replacementLanguages = { 232 "id", "he", "yi", "jv", "ro", "sr", /* replacement language codes */ 233 }; 234 235 private static final String[] _obsoleteLanguages = { 236 "in", "iw", "ji", "jw", "mo", "sh", /* obsolete language codes */ 237 }; 238 239 /* This list MUST contain a three-letter code for every two-letter code in the 240 list above, and they MUST ne in the same order (i.e., the same language must 241 be in the same place in both lists)! */ 242 private static final String[] _languages3 = { 243 "aar", "abk", "ace", "ach", "ada", "ady", "ave", "aeb", 244 "afr", "afh", "agq", "ain", "aka", "akk", "akz", "ale", 245 "aln", "alt", "amh", "arg", "ang", "anp", "ara", "arc", 246 "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "asm", 247 "asa", "ase", "ast", "ava", "avk", "awa", "aym", "aze", 248 "bak", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", 249 "bel", "bej", "bem", "bew", "bez", "bfd", "bfq", "bul", 250 "bgc", "bgn", "bho", "bis", "bik", "bin", "bjn", "bkm", "bla", 251 "bam", "ben", "bod", "bpy", "bqi", "bre", "bra", "brh", 252 "brx", "bos", "bss", "bua", "bug", "bum", "byn", "byv", 253 "cat", "cad", "car", "cay", "cch", "ccp", "che", "ceb", "cgg", 254 "cha", "chb", "chg", "chk", "chm", "chn", "cho", "chp", 255 "chr", "chy", "ckb", "cos", "cop", "cps", "cre", "crh", 256 "ces", "csb", "chu", "chv", "cym", 257 "dan", "dak", "dar", "dav", "day", "deu", "del", "den", 258 "dgr", "din", "dje", "doi", "dra", "dsb", "dua", "dum", 259 "div", "dyo", "dyu", "dzo", "dzg", 260 "ebu", "ewe", "efi", "egy", "eka", "ell", "elx", "eng", 261 "enm", "epo", "spa", "est", "eus", "ewo", 262 "fas", "fan", "fat", "ful", "fin", "fil", "fiu", "fij", 263 "fao", "fon", "fra", "frm", "fro", "frr", "frs", "fur", 264 "fry", 265 "gle", "gaa", "gay", "gba", "gla", "gem", "gez", "gil", 266 "glg", "gmh", "grn", "goh", "gon", "gor", "got", "grb", 267 "grc", "gsw", "guj", "guz", "glv", "gwi", 268 "hau", "hai", "haw", "heb", "hin", "hil", "him", "hit", 269 "hmn", "hmo", "hrv", "hsb", "hat", "hun", "hup", "hye", 270 "her", 271 "ina", "iba", "ibb", "ind", "ile", "ibo", "iii", "ijo", 272 "ipk", "ilo", "inc", "ine", "inh", "ido", "ira", "iro", 273 "isl", "ita", "iku", 274 "jpn", "jbo", "jgo", "jmc", "jpr", "jrb", "jav", 275 "kat", "kaa", "kab", "kac", "kaj", "kam", "kar", "kaw", 276 "kbd", "kbl", "kcg", "kde", "kea", "kfo", "kon", "kha", 277 "khi", "kho", "khq", "kik", "kua", "kaz", "kkj", "kal", 278 "kln", "khm", "kmb", "kan", "kor", "kok", "kos", "kpe", 279 "kau", "krc", "krl", "kro", "kru", "kas", "ksb", "ksf", 280 "ksh", "kur", "kum", "kut", "kom", "cor", "kir", 281 "lat", "lad", "lag", "lah", "lam", "ltz", "lez", "lug", 282 "lim", "lkt", "lin", "lao", "lol", "loz", "lit", "lub", 283 "lua", "lui", "lun", "luo", "lus", "luy", "lav", 284 "mad", "maf", "mag", "mai", "mak", "man", "map", "mas", 285 "mde", "mdf", "mdr", "men", "mer", "mfe", "mlg", "mga", 286 "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", 287 "mkh", "mal", "mon", "mnc", "mni", "mno", "moh", 288 "mos", "mar", "msa", "mlt", "mua", "mul", "mun", "mus", 289 "mwl", "mwr", "mya", "mye", "myn", "myv", 290 "nau", "nah", "nai", "nap", "naq", "nob", "nde", "nds", 291 "nep", "new", "ndo", "nia", "nic", "niu", "nld", "nmg", 292 "nno", "nnh", "nor", "nog", "non", "nqo", "nbl", "nso", 293 "nub", "nus", "nav", "nwc", "nya", "nym", "nyn", "nyo", 294 "nzi", 295 "oci", "oji", "orm", "ori", "oss", "osa", "ota", "oto", 296 "pan", "paa", "pag", "pal", "pam", "pap", "pau", "peo", 297 "phi", "phn", "pli", "pol", "pon", "pra", "pro", "pus", 298 "por", 299 "que", 300 "raj", "rap", "rar", "roh", "run", "ron", "roa", "rof", 301 "rom", "rus", "rup", "kin", "rwk", 302 "san", "sad", "sah", "sai", "sal", "sam", "saq", "sas", 303 "sat", "sba", "sbp", "srd", "scn", "sco", "snd", "sme", 304 "see", "seh", "sel", "sem", "ses", "sag", "sga", "sgn", 305 "shi", "shn", "shu", "sin", "sid", "sio", "sit", 306 "slk", "slv", "sla", "smo", "sma", "smi", "smj", "smn", 307 "sms", "sna", "snk", "som", "sog", "son", "sqi", "srp", 308 "srn", "srr", "ssw", "ssa", "ssy", "sot", "sun", "suk", 309 "sus", "sux", "swe", "swa", "swb", "syc", "syr", 310 "tam", "tai", "tel", "tem", "teo", "ter", "tet", "tgk", 311 "tha", "tir", "tig", "tiv", "tuk", "tkl", "tlh", 312 "tli", "tmh", "tsn", "ton", "tog", "tpi", "tur", "trv", 313 "tso", "tsi", "tat", "tum", "tup", "tut", "tvl", "twi", 314 "twq", "tah", "tyv", "tzm", 315 "udm", "uig", "uga", "ukr", "umb", "und", "urd", "uzb", 316 "vai", "ven", "vie", "vol", "vot", "vun", 317 "wln", "wae", "wak", "wal", "war", "was", "wen", "wol", 318 "xal", "xho", "xog", 319 "yao", "yap", "yav", "ybb", "yid", "yor", "ypk", "yue", 320 "zha", "zap", "zbl", "zen", "zho", "znd", "zul", "zun", 321 "zxx", "zza" }; 322 323 private static final String[] _obsoleteLanguages3 = { 324 /* "in", "iw", "ji", "jw", "mo", "sh", */ 325 "ind", "heb", "yid", "jaw", "ron", "srp" 326 }; 327 328 /* ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per 329 http://www.evertype.com/standards/iso3166/iso3166-1-en.html 330 added new codes keeping the old ones for compatibility 331 updated to include 1999/12/03 revisions *CWB*/ 332 333 /* RO(ROM) is now RO(ROU) according to 334 http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html 335 */ 336 /* This list MUST be in sorted order, and MUST contain only two-letter codes! */ 337 private static final String[] _countries = { 338 "AD", "AE", "AF", "AG", "AI", "AL", "AM", 339 "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", 340 "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", 341 "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", 342 "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", 343 "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", 344 "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DG", "DJ", "DK", 345 "DM", "DO", "DZ", "EA", "EC", "EE", "EG", "EH", "ER", 346 "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", 347 "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", 348 "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", 349 "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", 350 "IC", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", 351 "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", 352 "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", 353 "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", 354 "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", 355 "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", 356 "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", 357 "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", 358 "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", 359 "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", 360 "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", 361 "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", 362 "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", 363 "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", 364 "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", 365 "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", 366 "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", 367 "WS", "XK", "YE", "YT", "ZA", "ZM", "ZW" }; 368 369 private static final String[] _deprecatedCountries = { 370 "AN", "BU", "CS", "DD", "DY", "FX", "HV", "NH", "RH", "SU", "TP", "UK", "VD", "YD", "YU", "ZR" /* deprecated country list */ 371 }; 372 373 private static final String[] _replacementCountries = { 374 /* "AN", "BU", "CS", "DD", "DY", "FX", "HV", "NH", "RH", "SU", "TP", "UK", "VD", "YD", "YU", "ZR" */ 375 "CW", "MM", "RS", "DE", "BJ", "FR", "BF", "VU", "ZW", "RU", "TL", "GB", "VN", "YE", "RS", "CD" /* replacement country codes */ 376 }; 377 378 /* this table is used for three letter codes */ 379 private static final String[] _obsoleteCountries = { 380 "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR", /* obsolete country codes */ 381 }; 382 383 /* This list MUST contain a three-letter code for every two-letter code in 384 the above list, and they MUST be listed in the same order! */ 385 private static final String[] _countries3 = { 386 /* "AD", "AE", "AF", "AG", "AI", "AL", "AM", */ 387 "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", 388 /* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */ 389 "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE", 390 /* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */ 391 "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI", 392 /* "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", */ 393 "BEN", "BLM", "BMU", "BRN", "BOL", "BES", "BRA", "BHS", "BTN", "BVT", 394 /* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */ 395 "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG", 396 /* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */ 397 "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", 398 /* "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DG", "DJ", "DK", */ 399 "CUB", "CPV", "CUW", "CXR", "CYP", "CZE", "DEU", "DGA", "DJI", "DNK", 400 /* "DM", "DO", "DZ", "EA", "EC", "EE", "EG", "EH", "ER", */ 401 "DMA", "DOM", "DZA", "XEA", "ECU", "EST", "EGY", "ESH", "ERI", 402 /* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */ 403 "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", 404 /* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */ 405 "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL", 406 /* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */ 407 "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM", 408 /* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */ 409 "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN", 410 /* "IC", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */ 411 "XIC", "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL", 412 /* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */ 413 "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", 414 /* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */ 415 "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", 416 /* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */ 417 "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX", 418 /* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */ 419 "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD", 420 /* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */ 421 "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR", 422 /* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */ 423 "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", 424 /* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */ 425 "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", 426 /* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */ 427 "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG", 428 /* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */ 429 "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", 430 /* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */ 431 "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU", 432 /* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */ 433 "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM", 434 /* "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", */ 435 "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "SSD", "STP", "SLV", 436 /* "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */ 437 "SXM", "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK", 438 /* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */ 439 "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", 440 /* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */ 441 "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB", 442 /* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */ 443 "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", 444 /* "WS", "XK", "YE", "YT", "ZA", "ZM", "ZW", */ 445 "WSM", "XKK", "YEM", "MYT", "ZAF", "ZMB", "ZWE" }; 446 447 private static final String[] _obsoleteCountries3 = { 448 /* "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR" */ 449 "ANT", "BUR", "SCG", "FXX", "ROM", "SUN", "TMP", "YMD", "YUG", "ZAR", 450 }; 451 452 getCurrentCountryID(String oldID)453 public static String getCurrentCountryID(String oldID){ 454 int offset = findIndex(_deprecatedCountries, oldID); 455 if (offset >= 0) { 456 return _replacementCountries[offset]; 457 } 458 return oldID; 459 } 460 getCurrentLanguageID(String oldID)461 public static String getCurrentLanguageID(String oldID){ 462 int offset = findIndex(_obsoleteLanguages, oldID); 463 if (offset >= 0) { 464 return _replacementLanguages[offset]; 465 } 466 return oldID; 467 } 468 469 470 } 471