diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 6b62b3d79d..a41a4c1094 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -1622,11 +1622,7 @@ The variant cannot have dots in it. The 'rightmost' variant (@xxx) wins. The leftmost codepage (.xxx) wins. */ - char *correctedPOSIXLocale = 0; const char* posixID = uprv_getPOSIXIDForDefaultLocale(); - const char *p; - const char *q; - int32_t len; /* Format: (no spaces) ll [ _CC ] [ . MM ] [ @ VV] @@ -1634,38 +1630,29 @@ The leftmost codepage (.xxx) wins. l = lang, C = ctry, M = charmap, V = variant */ - if (gCorrectedPOSIXLocale != NULL) { + if (gCorrectedPOSIXLocale != nullptr) { return gCorrectedPOSIXLocale; } - if ((p = uprv_strchr(posixID, '.')) != NULL) { - /* assume new locale can't be larger than old one? */ - correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID)+1)); - /* Exit on memory allocation error. */ - if (correctedPOSIXLocale == NULL) { - return NULL; - } - uprv_strncpy(correctedPOSIXLocale, posixID, p-posixID); - correctedPOSIXLocale[p-posixID] = 0; + // Copy the ID into owned memory. + // Over-allocate in case we replace "@" with "__". + char *correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID) + 1 + 1)); + if (correctedPOSIXLocale == nullptr) { + return nullptr; + } + uprv_strcpy(correctedPOSIXLocale, posixID); - /* do not copy after the @ */ - if ((p = uprv_strchr(correctedPOSIXLocale, '@')) != NULL) { - correctedPOSIXLocale[p-correctedPOSIXLocale] = 0; + char *limit; + if ((limit = uprv_strchr(correctedPOSIXLocale, '.')) != nullptr) { + *limit = 0; + if ((limit = uprv_strchr(correctedPOSIXLocale, '@')) != nullptr) { + *limit = 0; } } /* Note that we scan the *uncorrected* ID. */ - if ((p = uprv_strrchr(posixID, '@')) != NULL) { - if (correctedPOSIXLocale == NULL) { - /* new locale can be 1 char longer than old one if @ -> __ */ - correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID)+2)); - /* Exit on memory allocation error. */ - if (correctedPOSIXLocale == NULL) { - return NULL; - } - uprv_strncpy(correctedPOSIXLocale, posixID, p-posixID); - correctedPOSIXLocale[p-posixID] = 0; - } + const char *p; + if ((p = uprv_strrchr(posixID, '@')) != nullptr) { p++; /* Take care of any special cases here.. */ @@ -1674,16 +1661,17 @@ The leftmost codepage (.xxx) wins. /* Don't worry about no__NY. In practice, it won't appear. */ } - if (uprv_strchr(correctedPOSIXLocale,'_') == NULL) { + if (uprv_strchr(correctedPOSIXLocale,'_') == nullptr) { uprv_strcat(correctedPOSIXLocale, "__"); /* aa@b -> aa__b (note this can make the new locale 1 char longer) */ } else { uprv_strcat(correctedPOSIXLocale, "_"); /* aa_CC@b -> aa_CC_b */ } - if ((q = uprv_strchr(p, '.')) != NULL) { + const char *q; + if ((q = uprv_strchr(p, '.')) != nullptr) { /* How big will the resulting string be? */ - len = (int32_t)(uprv_strlen(correctedPOSIXLocale) + (q-p)); + int32_t len = (int32_t)(uprv_strlen(correctedPOSIXLocale) + (q-p)); uprv_strncat(correctedPOSIXLocale, p, q-p); correctedPOSIXLocale[len] = 0; } @@ -1699,28 +1687,15 @@ The leftmost codepage (.xxx) wins. */ } - /* Was a correction made? */ - if (correctedPOSIXLocale != NULL) { - posixID = correctedPOSIXLocale; - } - else { - /* copy it, just in case the original pointer goes away. See j2395 */ - correctedPOSIXLocale = (char *)uprv_malloc(uprv_strlen(posixID) + 1); - /* Exit on memory allocation error. */ - if (correctedPOSIXLocale == NULL) { - return NULL; - } - posixID = uprv_strcpy(correctedPOSIXLocale, posixID); - } - - if (gCorrectedPOSIXLocale == NULL) { + if (gCorrectedPOSIXLocale == nullptr) { gCorrectedPOSIXLocale = correctedPOSIXLocale; gCorrectedPOSIXLocaleHeapAllocated = true; ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup); - correctedPOSIXLocale = NULL; + correctedPOSIXLocale = nullptr; } + posixID = gCorrectedPOSIXLocale; - if (correctedPOSIXLocale != NULL) { /* Was already set - clean up. */ + if (correctedPOSIXLocale != nullptr) { /* Was already set - clean up. */ uprv_free(correctedPOSIXLocale); } diff --git a/icu4c/source/common/ucurr.cpp b/icu4c/source/common/ucurr.cpp index 1062a9f309..78716013b1 100644 --- a/icu4c/source/common/ucurr.cpp +++ b/icu4c/source/common/ucurr.cpp @@ -85,30 +85,14 @@ static const char CURRENCY_MAP[] = "CurrencyMap"; // Tag for default meta-data, in CURRENCY_META static const char DEFAULT_META[] = "DEFAULT"; -// Variant for legacy pre-euro mapping in CurrencyMap -static const char VAR_PRE_EURO[] = "PREEURO"; - -// Variant for legacy euro mapping in CurrencyMap -static const char VAR_EURO[] = "EURO"; - // Variant delimiter static const char VAR_DELIM = '_'; -static const char VAR_DELIM_STR[] = "_"; - -// Variant for legacy euro mapping in CurrencyMap -//static const char VAR_DELIM_EURO[] = "_EURO"; - -#define VARIANT_IS_EMPTY 0 -#define VARIANT_IS_EURO 0x1 -#define VARIANT_IS_PREEURO 0x2 // Tag for localized display names (symbols) of currencies static const char CURRENCIES[] = "Currencies"; static const char CURRENCIES_NARROW[] = "Currencies%narrow"; static const char CURRENCYPLURALS[] = "CurrencyPlurals"; -static const UChar EUR_STR[] = {0x0045,0x0055,0x0052,0}; - // ISO codes mapping table static const UHashtable* gIsoCodes = NULL; static icu::UInitOnce gIsoCodesInitOnce = U_INITONCE_INITIALIZER; @@ -360,30 +344,10 @@ _findMetaData(const UChar* currency, UErrorCode& ec) { // ------------------------------------- -/** - * @see VARIANT_IS_EURO - * @see VARIANT_IS_PREEURO - */ -static uint32_t +static void idForLocale(const char* locale, char* countryAndVariant, int capacity, UErrorCode* ec) { - uint32_t variantType = 0; - // !!! this is internal only, assumes buffer is not null and capacity is sufficient - // Extract the country name and variant name. We only - // recognize two variant names, EURO and PREEURO. - char variant[ULOC_FULLNAME_CAPACITY]; ulocimp_getRegionForSupplementalData(locale, FALSE, countryAndVariant, capacity, ec); - uloc_getVariant(locale, variant, sizeof(variant), ec); - if (variant[0] != 0) { - variantType = (uint32_t)(0 == uprv_strcmp(variant, VAR_EURO)) - | ((uint32_t)(0 == uprv_strcmp(variant, VAR_PRE_EURO)) << 1); - if (variantType) - { - uprv_strcat(countryAndVariant, VAR_DELIM_STR); - uprv_strcat(countryAndVariant, variant); - } - } - return variantType; } // ------------------------------------------ @@ -568,7 +532,7 @@ ucurr_forLocale(const char* locale, // get country or country_variant in `id' char id[ULOC_FULLNAME_CAPACITY]; - uint32_t variantType = idForLocale(locale, id, UPRV_LENGTHOF(id), ec); + idForLocale(locale, id, UPRV_LENGTHOF(id), ec); if (U_FAILURE(*ec)) { return 0; } @@ -602,20 +566,6 @@ ucurr_forLocale(const char* locale, UResourceBundle *countryArray = ures_getByKey(rb, id, cm, &localStatus); UResourceBundle *currencyReq = ures_getByIndex(countryArray, 0, NULL, &localStatus); s = ures_getStringByKey(currencyReq, "id", &resLen, &localStatus); - - // Get the second item when PREEURO is requested, and this is a known Euro country. - // If the requested variant is PREEURO, and this isn't a Euro country, - // assume that the country changed over to the Euro in the future. - // This is probably an old version of ICU that hasn't been updated yet. - // The latest currency is probably correct. - if (U_SUCCESS(localStatus)) { - if ((variantType & VARIANT_IS_PREEURO) && u_strcmp(s, EUR_STR) == 0) { - currencyReq = ures_getByIndex(countryArray, 1, currencyReq, &localStatus); - s = ures_getStringByKey(currencyReq, "id", &resLen, &localStatus); - } else if ((variantType & VARIANT_IS_EURO)) { - s = EUR_STR; - } - } ures_close(currencyReq); ures_close(countryArray); } @@ -2305,7 +2255,7 @@ ucurr_countCurrencies(const char* locale, uloc_getKeywordValue(locale, "currency", id, ULOC_FULLNAME_CAPACITY, &localStatus); // get country or country_variant in `id' - /*uint32_t variantType =*/ idForLocale(locale, id, sizeof(id), ec); + idForLocale(locale, id, sizeof(id), ec); if (U_FAILURE(*ec)) { @@ -2421,7 +2371,7 @@ ucurr_forLocaleAndDate(const char* locale, resLen = uloc_getKeywordValue(locale, "currency", id, ULOC_FULLNAME_CAPACITY, &localStatus); // get country or country_variant in `id' - /*uint32_t variantType =*/ idForLocale(locale, id, sizeof(id), ec); + idForLocale(locale, id, sizeof(id), ec); if (U_FAILURE(*ec)) { return 0; diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 6b65c62622..6569452914 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -457,8 +457,6 @@ NULL typedef struct CanonicalizationMap { const char *id; /* input ID */ const char *canonicalID; /* canonicalized output ID */ - const char *keyword; /* keyword, or NULL if none */ - const char *value; /* keyword value, or NULL if kw==NULL */ } CanonicalizationMap; /** @@ -466,64 +464,14 @@ typedef struct CanonicalizationMap { * different semantic kinds of transformations. */ static const CanonicalizationMap CANONICALIZE_MAP[] = { - { "", "en_US_POSIX", NULL, NULL }, /* .NET name */ - { "c", "en_US_POSIX", NULL, NULL }, /* POSIX name */ - { "posix", "en_US_POSIX", NULL, NULL }, /* POSIX name (alias of C) */ - { "art_LOJBAN", "jbo", NULL, NULL }, /* registered name */ - { "az_AZ_CYRL", "az_Cyrl_AZ", NULL, NULL }, /* .NET name */ - { "az_AZ_LATN", "az_Latn_AZ", NULL, NULL }, /* .NET name */ - { "ca_ES_PREEURO", "ca_ES", "currency", "ESP" }, - { "de__PHONEBOOK", "de", "collation", "phonebook" }, /* Old ICU name */ - { "de_AT_PREEURO", "de_AT", "currency", "ATS" }, - { "de_DE_PREEURO", "de_DE", "currency", "DEM" }, - { "de_LU_PREEURO", "de_LU", "currency", "LUF" }, - { "el_GR_PREEURO", "el_GR", "currency", "GRD" }, - { "en_BE_PREEURO", "en_BE", "currency", "BEF" }, - { "en_IE_PREEURO", "en_IE", "currency", "IEP" }, - { "es__TRADITIONAL", "es", "collation", "traditional" }, /* Old ICU name */ - { "es_ES_PREEURO", "es_ES", "currency", "ESP" }, - { "eu_ES_PREEURO", "eu_ES", "currency", "ESP" }, - { "fi_FI_PREEURO", "fi_FI", "currency", "FIM" }, - { "fr_BE_PREEURO", "fr_BE", "currency", "BEF" }, - { "fr_FR_PREEURO", "fr_FR", "currency", "FRF" }, - { "fr_LU_PREEURO", "fr_LU", "currency", "LUF" }, - { "ga_IE_PREEURO", "ga_IE", "currency", "IEP" }, - { "gl_ES_PREEURO", "gl_ES", "currency", "ESP" }, - { "hi__DIRECT", "hi", "collation", "direct" }, /* Old ICU name */ - { "it_IT_PREEURO", "it_IT", "currency", "ITL" }, - { "ja_JP_TRADITIONAL", "ja_JP", "calendar", "japanese" }, /* Old ICU name */ - { "nb_NO_NY", "nn_NO", NULL, NULL }, /* "markus said this was ok" :-) */ - { "nl_BE_PREEURO", "nl_BE", "currency", "BEF" }, - { "nl_NL_PREEURO", "nl_NL", "currency", "NLG" }, - { "pt_PT_PREEURO", "pt_PT", "currency", "PTE" }, - { "sr_SP_CYRL", "sr_Cyrl_RS", NULL, NULL }, /* .NET name */ - { "sr_SP_LATN", "sr_Latn_RS", NULL, NULL }, /* .NET name */ - { "sr_YU_CYRILLIC", "sr_Cyrl_RS", NULL, NULL }, /* Linux name */ - { "th_TH_TRADITIONAL", "th_TH", "calendar", "buddhist" }, /* Old ICU name */ - { "uz_UZ_CYRILLIC", "uz_Cyrl_UZ", NULL, NULL }, /* Linux name */ - { "uz_UZ_CYRL", "uz_Cyrl_UZ", NULL, NULL }, /* .NET name */ - { "uz_UZ_LATN", "uz_Latn_UZ", NULL, NULL }, /* .NET name */ - { "zh_CHS", "zh_Hans", NULL, NULL }, /* .NET name */ - { "zh_CHT", "zh_Hant", NULL, NULL }, /* .NET name */ - { "zh_GAN", "gan", NULL, NULL }, /* registered name */ - { "zh_GUOYU", "zh", NULL, NULL }, /* registered name */ - { "zh_HAKKA", "hak", NULL, NULL }, /* registered name */ - { "zh_MIN_NAN", "nan", NULL, NULL }, /* registered name */ - { "zh_WUU", "wuu", NULL, NULL }, /* registered name */ - { "zh_XIANG", "hsn", NULL, NULL }, /* registered name */ - { "zh_YUE", "yue", NULL, NULL }, /* registered name */ -}; - -typedef struct VariantMap { - const char *variant; /* input ID */ - const char *keyword; /* keyword, or NULL if none */ - const char *value; /* keyword value, or NULL if kw==NULL */ -} VariantMap; - -static const VariantMap VARIANT_MAP[] = { - { "EURO", "currency", "EUR" }, - { "PINYIN", "collation", "pinyin" }, /* Solaris variant */ - { "STROKE", "collation", "stroke" } /* Solaris variant */ + { "art_LOJBAN", "jbo" }, /* registered name */ + { "zh_GAN", "gan" }, /* registered name */ + { "zh_GUOYU", "zh" }, /* registered name */ + { "zh_HAKKA", "hak" }, /* registered name */ + { "zh_MIN_NAN", "nan" }, /* registered name */ + { "zh_WUU", "wuu" }, /* registered name */ + { "zh_XIANG", "hsn" }, /* registered name */ + { "zh_YUE", "yue" }, /* registered name */ }; /* ### BCP47 Conversion *******************************************/ @@ -643,20 +591,12 @@ compareKeywordStructs(const void * /*context*/, const void *left, const void *ri return uprv_strcmp(leftString, rightString); } -/** - * Both addKeyword and addValue must already be in canonical form. - * Either both addKeyword and addValue are NULL, or neither is NULL. - * If they are not NULL they must be zero terminated. - * If addKeyword is not NULL is must have length small enough to fit in KeywordStruct.keyword. - */ static int32_t _getKeywords(const char *localeID, char prev, char *keywords, int32_t keywordCapacity, char *values, int32_t valuesCapacity, int32_t *valLen, UBool valuesToo, - const char* addKeyword, - const char* addValue, UErrorCode *status) { KeywordStruct keywordList[ULOC_MAX_NO_KEYWORDS]; @@ -755,33 +695,6 @@ _getKeywords(const char *localeID, } } while(pos); - /* Handle addKeyword/addValue. */ - if (addKeyword != NULL) { - UBool duplicate = FALSE; - U_ASSERT(addValue != NULL); - /* Search for duplicate; if found, do nothing. Explicit keyword - overrides addKeyword. */ - for (j=0; j= 0); - while (len-- != 0) { - char d = *str; - if (d == c) { - return (char*) str; - } else if (d == 0) { - break; - } - ++str; - } - return NULL; -} - /** * Lookup 'key' in the array 'list'. The array 'list' should contain * a NULL entry, followed by more entries, and a second NULL entry. @@ -1476,50 +1375,6 @@ _getVariant(const char *localeID, return _getVariantEx(localeID, prev, variant, variantCapacity, FALSE); } -/** - * Delete ALL instances of a variant from the given list of one or - * more variants. Example: "FOO_EURO_BAR_EURO" => "FOO_BAR". - * @param variants the source string of one or more variants, - * separated by '_'. This will be MODIFIED IN PLACE. Not zero - * terminated; if it is, trailing zero will NOT be maintained. - * @param variantsLen length of variants - * @param toDelete variant to delete, without separators, e.g. "EURO" - * or "PREEURO"; not zero terminated - * @param toDeleteLen length of toDelete - * @return number of characters deleted from variants - */ -static int32_t -_deleteVariant(char* variants, int32_t variantsLen, - const char* toDelete, int32_t toDeleteLen) -{ - int32_t delta = 0; /* number of chars deleted */ - for (;;) { - UBool flag = FALSE; - if (variantsLen < toDeleteLen) { - return delta; - } - if (uprv_strncmp(variants, toDelete, toDeleteLen) == 0 && - (variantsLen == toDeleteLen || - (flag=(variants[toDeleteLen] == '_')) != 0)) - { - int32_t d = toDeleteLen + (flag?1:0); - variantsLen -= d; - delta += d; - if (variantsLen > 0) { - uprv_memmove(variants, variants+d, variantsLen); - } - } else { - char* p = _strnchr(variants, variantsLen, '_'); - if (p == NULL) { - return delta; - } - ++p; - variantsLen -= (int32_t)(p - variants); - variants = p; - } - } -} - /* Keyword enumeration */ typedef struct UKeywordsContext { @@ -1698,8 +1553,6 @@ _canonicalize(const char* localeID, const char* tmpLocaleID; const char* keywordAssign = NULL; const char* separatorIndicator = NULL; - const char* addKeyword = NULL; - const char* addValue = NULL; char* name; char* variant = NULL; /* pointer into name, or NULL */ @@ -1864,27 +1717,6 @@ _canonicalize(const char* localeID, } } - /* Handle generic variants first */ - if (variant) { - for (j=0; j 0) { - if (len > 0 && name[len-1] == '_') { /* delete trailing '_' */ - --len; - } - addKeyword = VARIANT_MAP[j].keyword; - addValue = VARIANT_MAP[j].value; - break; - } - } - if (len > 0 && len <= nameCapacity && name[len-1] == '_') { /* delete trailing '_' */ - --len; - } - } - /* Look up the ID in the canonicalization map */ for (j=0; j 0) { - /* Most variants are ignorable like PREEURO, or collation variants. */ + /* Most variants are ignorable like collation variants. */ continue; } /* Start comparing only after the current index. @@ -728,7 +728,7 @@ TestConsistentCountryInfo(void) { } toVariantLen = uloc_getVariant(toLocale, toVariant, ULOC_FULLNAME_CAPACITY, &errorCode); if (toVariantLen > 0) { - /* Most variants are ignorable like PREEURO, or collation variants. */ + /* Most variants are ignorable like collation variants. */ /* They're a variant for a reason. */ continue; } diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index a5b6fe0988..6aec8ef47a 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -424,7 +424,6 @@ static void TestPrefixes() { {"i-hakka", "", "MX", "", "I-hakka_MX", "i-hakka_MX", NULL}, {"x-klingon", "", "US", "SANJOSE", "X-KLINGON_us_SANJOSE", "x-klingon_US_SANJOSE", NULL}, - {"zh", "Hans", "", "PINYIN", "zh-Hans-pinyin", "zh_Hans__PINYIN", "zh_Hans@collation=pinyin"}, {"hy", "", "", "AREVMDA", "hy_AREVMDA", "hy__AREVMDA", NULL}, {"de", "", "", "1901", "de-1901", "de__1901", NULL}, @@ -439,11 +438,16 @@ static void TestPrefixes() { {"no", "", "", "", "no@ny", "no@ny", "no__NY"}, {"el", "Latn", "", "", "el-latn", "el_Latn", NULL}, {"en", "Cyrl", "RU", "", "en-cyrl-ru", "en_Cyrl_RU", NULL}, - {"zh", "Hant", "TW", "STROKE", "zh-hant_TW_STROKE", "zh_Hant_TW_STROKE", "zh_Hant_TW@collation=stroke"}, {"qq", "Qqqq", "QQ", "QQ", "qq_Qqqq_QQ_QQ", "qq_Qqqq_QQ_QQ", NULL}, {"qq", "Qqqq", "", "QQ", "qq_Qqqq__QQ", "qq_Qqqq__QQ", NULL}, {"ab", "Cdef", "GH", "IJ", "ab_cdef_gh_ij", "ab_Cdef_GH_IJ", NULL}, /* total garbage */ - + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now use standard canonicalization. + {"zh", "Hans", "", "PINYIN", "zh-Hans-pinyin", "zh_Hans__PINYIN", "zh_Hans__PINYIN"}, + {"zh", "Hant", "TW", "STROKE", "zh-hant_TW_STROKE", "zh_Hant_TW_STROKE", "zh_Hant_TW_STROKE"}, + {NULL,NULL,NULL,NULL,NULL,NULL,NULL} }; @@ -1710,7 +1714,7 @@ static void TestKeywordVariants(void) "de_DE@euro", "de_DE@euro", "de_DE@euro", /* we probably should strip off the POSIX style variant @euro see #11690 */ - "de_DE@currency=EUR", + "de_DE_EURO", {"","","","","","",""}, 0, U_INVALID_FORMAT_ERROR /* must have '=' after '@' */ @@ -2129,57 +2133,21 @@ static void TestCanonicalization(void) const char *getNameID; /* expected getName() result */ const char *canonicalID; /* expected canonicalize() result */ } testCases[] = { - { "ca_ES_PREEURO-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage", - "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE", - "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"}, - { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" }, - { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" }, - { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" }, - { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=LUF" }, - { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" }, - { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" }, - { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" }, - { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" }, - { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" }, - { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" }, - { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" }, - { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" }, - { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" }, - { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" }, - { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" }, - { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" }, - { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" }, - { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" }, - { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" }, - { "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" }, - { "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" }, - { "en_GB@EURO", "en_GB@EURO", "en_GB@currency=EUR" }, /* POSIX ID */ - { "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" }, - { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" }, - { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" }, - { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" }, - { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" }, - { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" }, + { "ca_ES-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage", + "ca_ES_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE", + "ca_ES_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"}, { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" }, { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" }, - { "zh_CN_STROKE", "zh_CN_STROKE", "zh_CN@collation=stroke" }, { "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" }, { "en_US_POSIX", "en_US_POSIX", "en_US_POSIX" }, { "hy_AM_REVISED", "hy_AM_REVISED", "hy_AM_REVISED" }, { "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ }, { "no@ny", "no@ny", "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */ { "no-no.utf32@B", "no_NO.utf32@B", "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */ - { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */ + { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ_EURO" }, /* qz-qz uses private use iso codes */ { "en-BOONT", "en__BOONT", "en__BOONT" }, /* registered name */ { "de-1901", "de__1901", "de__1901" }, /* registered name */ { "de-1906", "de__1906", "de__1906" }, /* registered name */ - { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */ - { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */ - { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */ - { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */ - { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */ - { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */ - { "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */ /* posix behavior that used to be performed by getName */ { "mr.utf8", "mr.utf8", "mr" }, @@ -2194,12 +2162,6 @@ static void TestCanonicalization(void) { "en_Hant_IL_VALLEY_GIRL@ currency = EUR; calendar = Japanese ;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, /* already-canonical ids are not changed */ { "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, - /* PRE_EURO and EURO conversions don't affect other keywords */ - { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" }, - { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" }, - /* currency keyword overrides PRE_EURO and EURO currency */ - { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" }, - { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" }, /* norwegian is just too weird, if we handle things in their full generality */ { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ }, @@ -2210,9 +2172,55 @@ static void TestCanonicalization(void) { "ja_JP", "ja_JP", "ja_JP" }, /* test case for "i-default" */ - { "i-default", "en@x=i-default", "en@x=i-default" } + { "i-default", "en@x=i-default", "en@x=i-default" }, + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now use standard canonicalization. + { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES_PREEURO" }, + { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT_PREEURO" }, + { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE_PREEURO" }, + { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU_PREEURO" }, + { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR_PREEURO" }, + { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE_PREEURO" }, + { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE_PREEURO" }, + { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES_PREEURO" }, + { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES_PREEURO" }, + { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI_PREEURO" }, + { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE_PREEURO" }, + { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR_PREEURO" }, + { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU_PREEURO" }, + { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE_PREEURO" }, + { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES_PREEURO" }, + { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT_PREEURO" }, + { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE_PREEURO" }, + { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL_PREEURO" }, + { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT_PREEURO" }, + { "de__PHONEBOOK", "de__PHONEBOOK", "de__PHONEBOOK" }, + { "en_GB_EURO", "en_GB_EURO", "en_GB_EURO" }, + { "en_GB@EURO", "en_GB@EURO", "en_GB_EURO" }, /* POSIX ID */ + { "es__TRADITIONAL", "es__TRADITIONAL", "es__TRADITIONAL" }, + { "hi__DIRECT", "hi__DIRECT", "hi__DIRECT" }, + { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL" }, + { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH_TRADITIONAL" }, + { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW_STROKE" }, + { "zh__PINYIN", "zh__PINYIN", "zh__PINYIN" }, + { "zh_CN_STROKE", "zh_CN_STROKE", "zh_CN_STROKE" }, + { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_SP_CYRL" }, /* .NET name */ + { "sr-SP-Latn", "sr_SP_LATN", "sr_SP_LATN" }, /* .NET name */ + { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_YU_CYRILLIC" }, /* Linux name */ + { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_UZ_CYRL" }, /* .NET name */ + { "uz-UZ-Latn", "uz_UZ_LATN", "uz_UZ_LATN" }, /* .NET name */ + { "zh-CHS", "zh_CHS", "zh_CHS" }, /* .NET name */ + { "zh-CHT", "zh_CHT", "zh_CHT" }, /* .NET name This may change back to zh_Hant */ + /* PRE_EURO and EURO conversions don't affect other keywords */ + { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES_PREEURO@calendar=Japanese" }, + { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah" }, + /* currency keyword overrides PRE_EURO and EURO currency */ + { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR" }, + { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP" }, }; - + static const char* label[] = { "getName", "canonicalize" }; UErrorCode status = U_ZERO_ERROR; @@ -5941,7 +5949,6 @@ const char* const locale_to_langtag[][3] = { {"th_TH_TH", "th-TH-x-lvariant-th", NULL}, {"bogus", "bogus", "bogus"}, {"foooobarrr", "und", NULL}, - {"az_AZ_CYRL", "az-Cyrl-AZ", "az-Cyrl-AZ"}, {"aa_BB_CYRL", "aa-BB-x-lvariant-cyrl", NULL}, {"en_US_1234", "en-US-1234", "en-US-1234"}, {"en_US_VARIANTA_VARIANTB", "en-US-varianta-variantb", "en-US-varianta-variantb"}, @@ -5969,6 +5976,12 @@ const char* const locale_to_langtag[][3] = { {"en@a=bar;calendar=islamic-civil;x=u-foo", "en-a-bar-u-ca-islamic-civil-x-u-foo", "en-a-bar-u-ca-islamic-civil-x-u-foo"}, {"en@a=bar;attribute=baz;calendar=islamic-civil;x=u-foo", "en-a-bar-u-baz-ca-islamic-civil-x-u-foo", "en-a-bar-u-baz-ca-islamic-civil-x-u-foo"}, {"en@9=efg;a=baz", "en-9-efg-a-baz", "en-9-efg-a-baz"}, + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now uses standard canonicalization. + {"az_AZ_CYRL", "az-AZ-x-lvariant-cyrl", NULL}, + {NULL, NULL, NULL} }; @@ -6033,8 +6046,8 @@ static void TestBug20132(void) { UErrorCode status; int32_t len; - static const char inloc[] = "C"; - static const char expected[] = "en-US-u-va-posix"; + static const char inloc[] = "en-C"; + static const char expected[] = "en-x-lvariant-c"; const int32_t expected_len = (int32_t)uprv_strlen(expected); /* Before ICU-20132 was fixed, calling uloc_toLanguageTag() with a too small diff --git a/icu4c/source/test/cintltst/cnmdptst.c b/icu4c/source/test/cintltst/cnmdptst.c index 1b0d66e648..1af298e1d8 100644 --- a/icu4c/source/test/cintltst/cnmdptst.c +++ b/icu4c/source/test/cintltst/cnmdptst.c @@ -37,7 +37,6 @@ #define CHECK(status,str) if (U_FAILURE(status)) { log_err("FAIL: %s\n", str); return; } void addNumFrDepTest(TestNode** root); -static void TestCurrencyPreEuro(void); static void TestCurrencyObject(void); void addNumFrDepTest(TestNode** root) @@ -47,7 +46,6 @@ void addNumFrDepTest(TestNode** root) addTest(root, &TestExponential, "tsformat/cnmdptst/TestExponential"); addTest(root, &TestCurrencySign, "tsformat/cnmdptst/TestCurrencySign"); addTest(root, &TestCurrency, "tsformat/cnmdptst/TestCurrency"); - addTest(root, &TestCurrencyPreEuro, "tsformat/cnmdptst/TestCurrencyPreEuro"); addTest(root, &TestCurrencyObject, "tsformat/cnmdptst/TestCurrencyObject"); addTest(root, &TestRounding487, "tsformat/cnmdptst/TestRounding487"); addTest(root, &TestDoubleAttribute, "tsformat/cnmdptst/TestDoubleAttribute"); @@ -418,7 +416,7 @@ static void TestCurrency(void) UFieldPosition pos; UChar res[100]; UErrorCode status = U_ZERO_ERROR; - const char* locale[]={"fr_CA", "de_DE_PREEURO", "fr_FR_PREEURO"}; + const char* locale[]={"fr_CA", "de_DE@currency=DEM", "fr_FR@currency=FRF"}; const char* result[]={"1,50\\u00a0$", "1,50\\u00a0DM", "1,50\\u00a0F"}; log_verbose("\nTesting the number format with different currency patterns\n"); for(i=0; i < 3; i++) @@ -454,73 +452,6 @@ static void TestCurrency(void) free(str); } } -/** - * Test localized currency patterns for PREEURO variants. - */ -static void TestCurrencyPreEuro(void) -{ - UNumberFormat *currencyFmt; - UChar *str=NULL, *res=NULL; - int32_t lneed, i; - UFieldPosition pos; - UErrorCode status = U_ZERO_ERROR; - - const char* locale[]={ - "ca_ES_PREEURO", "de_LU_PREEURO", "en_IE_PREEURO", "fi_FI_PREEURO", "fr_LU_PREEURO", "it_IT_PREEURO", - "pt_PT_PREEURO", "de_AT_PREEURO", "el_GR_PREEURO", "es_ES_PREEURO", "fr_BE_PREEURO", "ga_IE_PREEURO", - "nl_BE_PREEURO", "de_DE_PREEURO", "en_BE_PREEURO", "eu_ES_PREEURO", "fr_FR_PREEURO", "gl_ES_PREEURO", - "nl_NL_PREEURO", - }; - - const char* result[]={ - "\\u20A7\\u00A02", "2\\u00A0F", "IEP\\u00A01.50", "1,50\\u00A0mk", "2\\u00A0F", "ITL\\u00A02", - "1$50\\u00A0\\u200B", "\\u00F6S\\u00A01,50", "1,50\\u00A0\\u0394\\u03C1\\u03C7", "2\\u00A0\\u20A7", "1,50\\u00A0FB", "IEP\\u00A01.50", - "BEF\\u00A01,50", "1,50\\u00A0DM", "1,50\\u00A0BEF", "\\u20A7\\u00A02", "1,50\\u00A0F", "2\\u00A0\\u20A7", - "NLG\\u00A01,50" - }; - - log_verbose("\nTesting the number format with different currency patterns\n"); - for(i=0; i < 19; i++) - { - char curID[256] = {0}; - uloc_canonicalize(locale[i], curID, 256, &status); - if(U_FAILURE(status)){ - log_data_err("Could not canonicalize %s. Error: %s (Are you missing data?)\n", locale[i], u_errorName(status)); - continue; - } - currencyFmt = unum_open(UNUM_CURRENCY, NULL,0,curID,NULL, &status); - - if(U_FAILURE(status)){ - log_data_err("Error in the construction of number format with style currency: %s (Are you missing data?)\n", - myErrorName(status)); - } else { - lneed=0; - lneed= unum_formatDouble(currencyFmt, 1.50, NULL, lneed, NULL, &status); - - if(status==U_BUFFER_OVERFLOW_ERROR){ - status=U_ZERO_ERROR; - str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); - pos.field = 0; - unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status); - } - - if(U_FAILURE(status)) { - log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) ); - } else { - res=(UChar*)malloc(sizeof(UChar) * (strlen(result[i])+1) ); - u_unescape(result[i],res,(int32_t)(strlen(result[i])+1)); - - if (u_strcmp(str, res) != 0){ - log_err("FAIL: Expected %s Got: %s for locale: %s\n", result[i],aescstrdup(str, -1),locale[i]); - } - } - } - - unum_close(currencyFmt); - free(str); - free(res); - } -} /** * Test currency "object" (we use this name to match the other C++ diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index fc64851e24..e933c7cd3e 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -2747,7 +2747,7 @@ void CalendarRegressionTest::TestDeprecates(void) { UErrorCode status = U_ZERO_ERROR; Calendar *c1 = Calendar::createInstance("ja_JP@calendar=japanese",status); - Calendar *c2 = Calendar::createInstance("ja_JP_TRADITIONAL",status); + Calendar *c2 = Calendar::createInstance("ja_JP@calendar=japanese",status); if(!c1 || !c2 || U_FAILURE(status)) { dataerrln("Couldn't create calendars for roll of HOUR: %s", u_errorName(status)); @@ -2782,7 +2782,7 @@ void CalendarRegressionTest::TestDeprecates(void) status = U_ZERO_ERROR; - c1 = Calendar::createInstance("th_TH_TRADITIONAL",status); + c1 = Calendar::createInstance("th_TH@calendar=buddhist",status); c2 = Calendar::createInstance("th_TH@calendar=buddhist",status); if(!c1 || !c2 || U_FAILURE(status)) { diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp index 1e79576d88..ea962f0444 100644 --- a/icu4c/source/test/intltest/incaltst.cpp +++ b/icu4c/source/test/intltest/incaltst.cpp @@ -100,7 +100,6 @@ IntlCalendarTest::TestTypes() "en_US_VALLEYGIRL@collation=phonebook;calendar=gregorian", "ja_JP@calendar=japanese", "th_TH@calendar=buddhist", - "ja_JP_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH_TRADITIONAL@calendar=gregorian", "en_US", @@ -114,7 +113,6 @@ IntlCalendarTest::TestTypes() "gregorian", "japanese", "buddhist", - "japanese", "buddhist", "gregorian", "gregorian", @@ -490,8 +488,8 @@ void IntlCalendarTest::TestBuddhistFormat() { void IntlCalendarTest::TestJapaneseFormat() { Calendar *cal; UErrorCode status = U_ZERO_ERROR; - cal = Calendar::createInstance("ja_JP_TRADITIONAL", status); - CHECK(status, UnicodeString("Creating ja_JP_TRADITIONAL calendar")); + cal = Calendar::createInstance("ja_JP@calendar=japanese", status); + CHECK(status, UnicodeString("Creating ja_JP@calendar=japanese calendar")); Calendar *cal2 = cal->clone(); delete cal; @@ -577,7 +575,7 @@ void IntlCalendarTest::TestJapaneseFormat() { { UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5"); UDate expectDate = 999932400000.0; // Testing a recent date - Locale loc("ja_JP_TRADITIONAL"); // legacy + Locale loc("ja_JP@calendar=japanese"); status = U_ZERO_ERROR; simpleTest(loc, expect, expectDate, status); diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 0a0855ca71..3e0c5cbf58 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -1199,8 +1199,8 @@ LocaleTest::TestEuroSupport() "el_GR", "en_BE", "en_IE", - "en_GB_EURO", - "en_US_EURO", + "en_GB@currency=EUR", + "en_US@currency=EUR", "es_ES", "eu_ES", "fi_FI", @@ -1259,20 +1259,15 @@ LocaleTest::TestEuroSupport() if (dollarStr != resultStr) { errcheckln(status, "Fail: en_US didn't return USD - %s", u_errorName(status)); } - ucurr_forLocale("en_US_EURO", tmp, 4, &status); + ucurr_forLocale("en_US@currency=EUR", tmp, 4, &status); resultStr.setTo(tmp); if (euroStr != resultStr) { - errcheckln(status, "Fail: en_US_EURO didn't return EUR - %s", u_errorName(status)); + errcheckln(status, "Fail: en_US@currency=EUR didn't return EUR - %s", u_errorName(status)); } - ucurr_forLocale("en_GB_EURO", tmp, 4, &status); + ucurr_forLocale("en_GB@currency=EUR", tmp, 4, &status); resultStr.setTo(tmp); if (euroStr != resultStr) { - errcheckln(status, "Fail: en_GB_EURO didn't return EUR - %s", u_errorName(status)); - } - ucurr_forLocale("en_US_PREEURO", tmp, 4, &status); - resultStr.setTo(tmp); - if (dollarStr != resultStr) { - errcheckln(status, "Fail: en_US_PREEURO didn't fallback to en_US - %s", u_errorName(status)); + errcheckln(status, "Fail: en_GB@currency=EUR didn't return EUR - %s", u_errorName(status)); } ucurr_forLocale("en_US_Q", tmp, 4, &status); resultStr.setTo(tmp); @@ -2476,40 +2471,9 @@ void LocaleTest::TestCanonicalization(void) const char *getNameID; /* expected getName() result */ const char *canonicalID; /* expected canonicalize() result */ } testCases[] = { - { "", "", "en_US_POSIX" }, - { "C", "c", "en_US_POSIX" }, - { "POSIX", "posix", "en_US_POSIX" }, - { "ca_ES_PREEURO-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage", - "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE", - "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"}, - { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" }, - { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" }, - { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" }, - { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=LUF" }, - { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" }, - { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" }, - { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" }, - { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" }, - { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" }, - { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" }, - { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" }, - { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" }, - { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" }, - { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" }, - { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" }, - { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" }, - { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" }, - { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" }, - { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" }, - { "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" }, - { "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" }, - { "en_GB@EURO", "en_GB@EURO", "en_GB@currency=EUR" }, /* POSIX ID */ - { "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" }, - { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" }, - { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" }, - { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" }, - { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" }, - { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" }, + { "ca_ES-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage", + "ca_ES_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE", + "ca_ES_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"}, { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" }, { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" }, { "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" }, @@ -2518,19 +2482,12 @@ void LocaleTest::TestCanonicalization(void) { "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ }, { "no@ny", "no@ny", "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */ { "no-no.utf32@B", "no_NO.utf32@B", "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */ - { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */ + { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ_EURO" }, /* qz-qz uses private use iso codes */ // NOTE: uloc_getName() works on en-BOONT, but Locale() parser considers it BOGUS // TODO: unify this behavior { "en-BOONT", "en__BOONT", "en__BOONT" }, /* registered name */ { "de-1901", "de__1901", "de__1901" }, /* registered name */ { "de-1906", "de__1906", "de__1906" }, /* registered name */ - { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */ - { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */ - { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */ - { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */ - { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */ - { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */ - { "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */ /* posix behavior that used to be performed by getName */ { "mr.utf8", "mr.utf8", "mr" }, @@ -2545,19 +2502,61 @@ void LocaleTest::TestCanonicalization(void) { "en_Hant_IL_VALLEY_GIRL@ currency = EUR; calendar = Japanese ;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, /* already-canonical ids are not changed */ { "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, - /* PRE_EURO and EURO conversions don't affect other keywords */ - { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" }, - { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" }, - /* currency keyword overrides PRE_EURO and EURO currency */ - { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" }, - { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" }, /* norwegian is just too weird, if we handle things in their full generality */ { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ }, /* test cases reflecting internal resource bundle usage */ { "root@kw=foo", "root@kw=foo", "root@kw=foo" }, { "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" }, - { "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese" } + { "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese" }, + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now use standard canonicalization. + { "", "", "" }, + { "C", "c", "c" }, + { "POSIX", "posix", "posix" }, + { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES_PREEURO" }, + { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT_PREEURO" }, + { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE_PREEURO" }, + { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU_PREEURO" }, + { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR_PREEURO" }, + { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE_PREEURO" }, + { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE_PREEURO" }, + { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES_PREEURO" }, + { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES_PREEURO" }, + { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI_PREEURO" }, + { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE_PREEURO" }, + { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR_PREEURO" }, + { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU_PREEURO" }, + { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE_PREEURO" }, + { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES_PREEURO" }, + { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT_PREEURO" }, + { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE_PREEURO" }, + { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL_PREEURO" }, + { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT_PREEURO" }, + { "de__PHONEBOOK", "de__PHONEBOOK", "de__PHONEBOOK" }, + { "en_GB_EURO", "en_GB_EURO", "en_GB_EURO" }, + { "en_GB@EURO", "en_GB@EURO", "en_GB_EURO" }, /* POSIX ID */ + { "es__TRADITIONAL", "es__TRADITIONAL", "es__TRADITIONAL" }, + { "hi__DIRECT", "hi__DIRECT", "hi__DIRECT" }, + { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL" }, + { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH_TRADITIONAL" }, + { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW_STROKE" }, + { "zh__PINYIN", "zh__PINYIN", "zh__PINYIN" }, + { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_SP_CYRL" }, /* .NET name */ + { "sr-SP-Latn", "sr_SP_LATN", "sr_SP_LATN" }, /* .NET name */ + { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_YU_CYRILLIC" }, /* Linux name */ + { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_UZ_CYRL" }, /* .NET name */ + { "uz-UZ-Latn", "uz_UZ_LATN", "uz_UZ_LATN" }, /* .NET name */ + { "zh-CHS", "zh_CHS", "zh_CHS" }, /* .NET name */ + { "zh-CHT", "zh_CHT", "zh_CHT" }, /* .NET name This may change back to zh_Hant */ + /* PRE_EURO and EURO conversions don't affect other keywords */ + { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES_PREEURO@calendar=Japanese" }, + { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah" }, + /* currency keyword overrides PRE_EURO and EURO currency */ + { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR" }, + { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP" }, }; static const char* label[] = { "createFromName", "createCanonical", "Locale" }; @@ -2886,10 +2885,6 @@ void LocaleTest::TestCurrencyByDate(void) if (u_strcmp(USD, TMP) != 0) { errcheckln(status, "Fail: en_US didn't return USD - %s", u_errorName(status)); } - ucurr_forLocaleAndDate("en_US_PREEURO", date, 1, TMP, 4, &status); - if (u_strcmp(USD, TMP) != 0) { - errcheckln(status, "Fail: en_US_PREEURO didn't fallback to en_US - %s", u_errorName(status)); - } ucurr_forLocaleAndDate("en_US_Q", date, 1, TMP, 4, &status); if (u_strcmp(USD, TMP) != 0) { errcheckln(status, "Fail: en_US_Q didn't fallback to en_US - %s", u_errorName(status)); @@ -3026,7 +3021,7 @@ void LocaleTest::TestForLanguageTag() { void LocaleTest::TestToLanguageTag() { IcuTestErrorCode status(*this, "TestToLanguageTag()"); - static const Locale loc_c("C"); + static const Locale loc_c("en_US_POSIX"); static const Locale loc_en("en_US"); static const Locale loc_af("af@calendar=coptic;t=ar-i0-handwrit;x=foo"); static const Locale loc_ext("en@0=abc;a=xyz"); diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 3babb314c1..86629618f0 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -877,15 +877,15 @@ NumberFormatTest::escape(UnicodeString& s) // ------------------------------------- static const char* testCases[][2]= { /* locale ID */ /* expected */ - {"ca_ES_PREEURO", "\\u20A7\\u00A01.150" }, - {"de_LU_PREEURO", "1,150\\u00A0F" }, - {"el_GR_PREEURO", "1.150,50\\u00A0\\u0394\\u03C1\\u03C7" }, - {"en_BE_PREEURO", "1.150,50\\u00A0BEF" }, - {"es_ES_PREEURO", "1.150\\u00A0\\u20A7" }, - {"eu_ES_PREEURO", "\\u20A7\\u00A01.150" }, - {"gl_ES_PREEURO", "1.150\\u00A0\\u20A7" }, - {"it_IT_PREEURO", "ITL\\u00A01.150" }, - {"pt_PT_PREEURO", "1,150$50\\u00A0\\u200B"}, // per cldrbug 7670 + {"ca_ES@currency=ESP", "\\u20A7\\u00A01.150" }, + {"de_LU@currency=LUF", "1,150\\u00A0F" }, + {"el_GR@currency=GRD", "1.150,50\\u00A0\\u0394\\u03C1\\u03C7" }, + {"en_BE@currency=BEF", "1.150,50\\u00A0BEF" }, + {"es_ES@currency=ESP", "1.150\\u00A0\\u20A7" }, + {"eu_ES@currency=ESP", "\\u20A7\\u00A01.150" }, + {"gl_ES@currency=ESP", "1.150\\u00A0\\u20A7" }, + {"it_IT@currency=ITL", "ITL\\u00A01.150" }, + {"pt_PT@currency=PTE", "1,150$50\\u00A0\\u200B"}, // per cldrbug 7670 {"en_US@currency=JPY", "\\u00A51,150"}, {"en_US@currency=jpy", "\\u00A51,150"}, {"en-US-u-cu-jpy", "\\u00A51,150"} @@ -910,7 +910,7 @@ NumberFormatTest::TestCurrency(void) delete currencyFmt; s.truncate(0); char loc[256]={0}; - int len = uloc_canonicalize("de_DE_PREEURO", loc, 256, &status); + int len = uloc_canonicalize("de_DE@currency=DEM", loc, 256, &status); (void)len; // Suppress unused variable warning. currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc),status); currencyFmt->format(1.50, s); @@ -919,7 +919,7 @@ NumberFormatTest::TestCurrency(void) errln((UnicodeString)"FAIL: Expected 1,50DM but got " + s); delete currencyFmt; s.truncate(0); - len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status); + len = uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status); currencyFmt = NumberFormat::createCurrencyInstance(Locale(loc), status); currencyFmt->format(1.50, s); logln((UnicodeString)"Un pauvre en France a....." + s); @@ -1929,25 +1929,19 @@ void NumberFormatTest::TestRegCurrency(void) { UChar YEN[4]; ucurr_forLocale("ja_JP", YEN, 4, &status); UChar TMP[4]; - static const UChar QQQ[] = {0x51, 0x51, 0x51, 0}; + if(U_FAILURE(status)) { errcheckln(status, "Unable to get currency for locale, error %s", u_errorName(status)); return; } UCurrRegistryKey enkey = ucurr_register(YEN, "en_US", &status); - UCurrRegistryKey enUSEUROkey = ucurr_register(QQQ, "en_US_EURO", &status); ucurr_forLocale("en_US", TMP, 4, &status); if (u_strcmp(YEN, TMP) != 0) { errln("FAIL: didn't return YEN registered for en_US"); } - ucurr_forLocale("en_US_EURO", TMP, 4, &status); - if (u_strcmp(QQQ, TMP) != 0) { - errln("FAIL: didn't return QQQ for en_US_EURO"); - } - int32_t fallbackLen = ucurr_forLocale("en_XX_BAR", TMP, 4, &status); if (fallbackLen) { errln("FAIL: tried to fallback en_XX_BAR"); @@ -1964,26 +1958,11 @@ void NumberFormatTest::TestRegCurrency(void) { } status = U_ZERO_ERROR; // reset - ucurr_forLocale("en_US_EURO", TMP, 4, &status); - if (u_strcmp(QQQ, TMP) != 0) { - errln("FAIL: didn't return QQQ for en_US_EURO after unregister of en_US"); - } - ucurr_forLocale("en_US_BLAH", TMP, 4, &status); if (u_strcmp(USD, TMP) != 0) { errln("FAIL: could not find USD for en_US_BLAH after unregister of en"); } status = U_ZERO_ERROR; // reset - - if (!ucurr_unregister(enUSEUROkey, &status)) { - errln("FAIL: couldn't unregister enUSEUROkey"); - } - - ucurr_forLocale("en_US_EURO", TMP, 4, &status); - if (u_strcmp(EUR, TMP) != 0) { - errln("FAIL: didn't return EUR for en_US_EURO after unregister of en_US_EURO"); - } - status = U_ZERO_ERROR; // reset #endif } diff --git a/icu4c/source/test/intltest/numrgts.cpp b/icu4c/source/test/intltest/numrgts.cpp index 2cfc4eecd6..fe244baf81 100644 --- a/icu4c/source/test/intltest/numrgts.cpp +++ b/icu4c/source/test/intltest/numrgts.cpp @@ -850,7 +850,7 @@ void NumberFormatRegressionTest::Test4092480 (void) void NumberFormatRegressionTest::Test4087244 (void) { UErrorCode status = U_ZERO_ERROR; char loc[256] = {0}; - uloc_canonicalize("pt_PT_PREEURO", loc, 256, &status); + uloc_canonicalize("pt_PT@currency=PTE", loc, 256, &status); Locale *de = new Locale(loc); NumberFormat *nf = NumberFormat::createCurrencyInstance(*de, status); if(U_FAILURE(status)) { @@ -918,7 +918,7 @@ void NumberFormatRegressionTest::Test4070798 (void) UErrorCode status = U_ZERO_ERROR; char loc[256]={0}; - int len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status); + int len = uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status); (void)len; // Suppress set but not used warning. formatter = NumberFormat::createInstance(Locale(loc), status); if(U_FAILURE(status)) { @@ -937,7 +937,7 @@ void NumberFormatRegressionTest::Test4070798 (void) " Received " + tempString ); } delete formatter; - len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status); + len = uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status); formatter = NumberFormat::createCurrencyInstance(loc, status); failure(status, "NumberFormat::createCurrencyInstance", loc); tempString.remove(); @@ -952,7 +952,7 @@ void NumberFormatRegressionTest::Test4070798 (void) } delete formatter; - uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status); + uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status); formatter = NumberFormat::createPercentInstance(Locale(loc), status); failure(status, "NumberFormat::createPercentInstance", loc); tempString.remove(); @@ -1061,7 +1061,7 @@ void NumberFormatRegressionTest::Test4071014 (void) UErrorCode status = U_ZERO_ERROR; char loc[256]={0}; - uloc_canonicalize("de_DE_PREEURO", loc, 256, &status); + uloc_canonicalize("de_DE@currency=DEM", loc, 256, &status); formatter = NumberFormat::createInstance(Locale(loc), status); if (failure(status, "NumberFormat::createInstance", loc, TRUE)){ delete formatter; @@ -1078,7 +1078,7 @@ void NumberFormatRegressionTest::Test4071014 (void) " Received " + tempString ); } delete formatter; - uloc_canonicalize("de_DE_PREEURO", loc, 256, &status); + uloc_canonicalize("de_DE@currency=DEM", loc, 256, &status); formatter = NumberFormat::createCurrencyInstance(Locale(loc), status); failure(status, "NumberFormat::createCurrencyInstance", loc); tempString.remove(); @@ -1127,7 +1127,7 @@ void NumberFormatRegressionTest::Test4071859 (void) UErrorCode status = U_ZERO_ERROR; char loc[256]={0}; - uloc_canonicalize("it_IT_PREEURO", loc, 256, &status); + uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status); formatter = NumberFormat::createInstance(Locale(loc), status); if (failure(status, "NumberFormat::createNumberInstance", TRUE)){ delete formatter; @@ -1143,7 +1143,7 @@ void NumberFormatRegressionTest::Test4071859 (void) " Received " + tempString ); } delete formatter; - uloc_canonicalize("it_IT_PREEURO", loc, 256, &status); + uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status); formatter = NumberFormat::createCurrencyInstance(Locale(loc), status); failure(status, "NumberFormat::createCurrencyInstance"); tempString.remove(); @@ -1157,7 +1157,7 @@ void NumberFormatRegressionTest::Test4071859 (void) " Received " + tempString ); } delete formatter; - uloc_canonicalize("it_IT_PREEURO", loc, 256, &status); + uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status); formatter = NumberFormat::createPercentInstance(Locale(loc), status); failure(status, "NumberFormat::createPercentInstance"); tempString.remove(); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java index 64e84f81d1..3efb00f321 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/NumberFormat.java @@ -1447,8 +1447,7 @@ public abstract class NumberFormat extends UFormat { DecimalFormatSymbols symbols = new DecimalFormatSymbols(desiredLocale); // Here we assume that the locale passed in is in the canonical - // form, e.g: pt_PT_@currency=PTE not pt_PT_PREEURO - // This style wont work for currency plural format. + // form, e.g: pt_PT_@currency=PTE // For currency plural format, the pattern is get from // the locale (from CurrencyUnitPatterns) without override. if (choice == CURRENCYSTYLE || choice == ISOCURRENCYSTYLE || choice == ACCOUNTINGCURRENCYSTYLE diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java b/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java index f1f400c6eb..51bccd5e35 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java @@ -249,40 +249,18 @@ public class Currency extends MeasureUnit { * Instantiate a currency from resource data. */ /* package */ static Currency createCurrency(ULocale loc) { - String variant = loc.getVariant(); - if ("EURO".equals(variant)) { - return getInstance(EUR_STR); - } - - // Cache the currency by region, and whether variant=PREEURO. + // Cache the currency by region. // Minimizes the size of the cache compared with caching by ULocale. String key = ULocale.getRegionForSupplementalData(loc, false); - if ("PREEURO".equals(variant)) { - key = key + '-'; - } return regionCurrencyCache.getInstance(key, null); } private static Currency loadCurrency(String key) { - String region; - boolean isPreEuro; - if (key.endsWith("-")) { - region = key.substring(0, key.length() - 1); - isPreEuro = true; - } else { - region = key; - isPreEuro = false; - } + String region = key; CurrencyMetaInfo info = CurrencyMetaInfo.getInstance(); List list = info.currencies(CurrencyFilter.onRegion(region)); if (!list.isEmpty()) { String code = list.get(0); - if (isPreEuro && EUR_STR.equals(code)) { - if (list.size() < 2) { - return null; - } - code = list.get(1); - } return getInstance(code); } return null; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java index f650784772..54827e38e5 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java @@ -78,9 +78,6 @@ import com.ibm.icu.text.LocaleDisplayNames.DialectHandling; *
    *
  • POSIX ids are converted to ICU format IDs
  • *
  • 'grandfathered' 3066 ids are converted to ICU standard form
  • - *
  • 'PREEURO' and 'EURO' variants are converted to currency keyword form, - * with the currency - * id appropriate to the country of the locale (for PREEURO) or EUR (for EURO). *
* All ULocale constructors automatically normalize the locale id. To handle * POSIX ids, canonicalize can be called to convert the id @@ -334,75 +331,28 @@ public final class ULocale implements Serializable, Comparable { private transient volatile LocaleExtensions extensions; /** - * This table lists pairs of locale ids for canonicalization. The + * This table lists pairs of locale ids for canonicalization. * The 1st item is the normalized id. The 2nd item is the - * canonicalized id. The 3rd is the keyword. The 4th is the keyword value. + * canonicalized id. */ private static String[][] CANONICALIZE_MAP = { - { "C", "en_US_POSIX", null, null }, /* POSIX name */ - { "art_LOJBAN", "jbo", null, null }, /* registered name */ - { "az_AZ_CYRL", "az_Cyrl_AZ", null, null }, /* .NET name */ - { "az_AZ_LATN", "az_Latn_AZ", null, null }, /* .NET name */ - { "ca_ES_PREEURO", "ca_ES", "currency", "ESP" }, - { "cel_GAULISH", "cel__GAULISH", null, null }, /* registered name */ - { "de_1901", "de__1901", null, null }, /* registered name */ - { "de_1906", "de__1906", null, null }, /* registered name */ - { "de__PHONEBOOK", "de", "collation", "phonebook" }, /* Old ICU name */ - { "de_AT_PREEURO", "de_AT", "currency", "ATS" }, - { "de_DE_PREEURO", "de_DE", "currency", "DEM" }, - { "de_LU_PREEURO", "de_LU", "currency", "EUR" }, - { "el_GR_PREEURO", "el_GR", "currency", "GRD" }, - { "en_BOONT", "en__BOONT", null, null }, /* registered name */ - { "en_SCOUSE", "en__SCOUSE", null, null }, /* registered name */ - { "en_BE_PREEURO", "en_BE", "currency", "BEF" }, - { "en_IE_PREEURO", "en_IE", "currency", "IEP" }, - { "es__TRADITIONAL", "es", "collation", "traditional" }, /* Old ICU name */ - { "es_ES_PREEURO", "es_ES", "currency", "ESP" }, - { "eu_ES_PREEURO", "eu_ES", "currency", "ESP" }, - { "fi_FI_PREEURO", "fi_FI", "currency", "FIM" }, - { "fr_BE_PREEURO", "fr_BE", "currency", "BEF" }, - { "fr_FR_PREEURO", "fr_FR", "currency", "FRF" }, - { "fr_LU_PREEURO", "fr_LU", "currency", "LUF" }, - { "ga_IE_PREEURO", "ga_IE", "currency", "IEP" }, - { "gl_ES_PREEURO", "gl_ES", "currency", "ESP" }, - { "hi__DIRECT", "hi", "collation", "direct" }, /* Old ICU name */ - { "it_IT_PREEURO", "it_IT", "currency", "ITL" }, - { "ja_JP_TRADITIONAL", "ja_JP", "calendar", "japanese" }, - //{ "nb_NO_NY", "nn_NO", null, null }, - { "nl_BE_PREEURO", "nl_BE", "currency", "BEF" }, - { "nl_NL_PREEURO", "nl_NL", "currency", "NLG" }, - { "pt_PT_PREEURO", "pt_PT", "currency", "PTE" }, - { "sl_ROZAJ", "sl__ROZAJ", null, null }, /* registered name */ - { "sr_SP_CYRL", "sr_Cyrl_RS", null, null }, /* .NET name */ - { "sr_SP_LATN", "sr_Latn_RS", null, null }, /* .NET name */ - { "sr_YU_CYRILLIC", "sr_Cyrl_RS", null, null }, /* Linux name */ - { "th_TH_TRADITIONAL", "th_TH", "calendar", "buddhist" }, /* Old ICU name */ - { "uz_UZ_CYRILLIC", "uz_Cyrl_UZ", null, null }, /* Linux name */ - { "uz_UZ_CYRL", "uz_Cyrl_UZ", null, null }, /* .NET name */ - { "uz_UZ_LATN", "uz_Latn_UZ", null, null }, /* .NET name */ - { "zh_CHS", "zh_Hans", null, null }, /* .NET name */ - { "zh_CHT", "zh_Hant", null, null }, /* .NET name */ - { "zh_GAN", "zh__GAN", null, null }, /* registered name */ - { "zh_GUOYU", "zh", null, null }, /* registered name */ - { "zh_HAKKA", "zh__HAKKA", null, null }, /* registered name */ - { "zh_MIN", "zh__MIN", null, null }, /* registered name */ - { "zh_MIN_NAN", "zh__MINNAN", null, null }, /* registered name */ - { "zh_WUU", "zh__WUU", null, null }, /* registered name */ - { "zh_XIANG", "zh__XIANG", null, null }, /* registered name */ - { "zh_YUE", "zh__YUE", null, null } /* registered name */ + { "art_LOJBAN", "jbo" }, /* registered name */ + { "cel_GAULISH", "cel__GAULISH" }, /* registered name */ + { "de_1901", "de__1901" }, /* registered name */ + { "de_1906", "de__1906" }, /* registered name */ + { "en_BOONT", "en__BOONT" }, /* registered name */ + { "en_SCOUSE", "en__SCOUSE" }, /* registered name */ + { "sl_ROZAJ", "sl__ROZAJ" }, /* registered name */ + { "zh_GAN", "zh__GAN" }, /* registered name */ + { "zh_GUOYU", "zh" }, /* registered name */ + { "zh_HAKKA", "zh__HAKKA" }, /* registered name */ + { "zh_MIN", "zh__MIN" }, /* registered name */ + { "zh_MIN_NAN", "zh__MINNAN" }, /* registered name */ + { "zh_WUU", "zh__WUU" }, /* registered name */ + { "zh_XIANG", "zh__XIANG" }, /* registered name */ + { "zh_YUE", "zh__YUE" } /* registered name */ }; - /** - * This table lists pairs of locale ids for canonicalization. - * The first item is the normalized variant id. - */ - private static String[][] variantsToKeywords = { - { "EURO", "currency", "EUR" }, - { "PINYIN", "collation", "pinyin" }, /* Solaris variant */ - { "STROKE", "collation", "stroke" } /* Solaris variant */ - }; - - /** * Private constructor used by static initializers. */ @@ -1180,44 +1130,19 @@ public final class ULocale implements Serializable, Comparable { String baseName = parser.getBaseName(); boolean foundVariant = false; - // formerly, we always set to en_US_POSIX if the basename was empty, but - // now we require that the entire id be empty, so that "@foo=bar" - // will pass through unchanged. - // {dlf} I'd rather keep "" unchanged. if (localeID.equals("")) { return ""; - // return "en_US_POSIX"; } // we have an ID in the form xx_Yyyy_ZZ_KKKKK - /* convert the variants to appropriate ID */ - for (int i = 0; i < variantsToKeywords.length; i++) { - String[] vals = variantsToKeywords[i]; - int idx = baseName.lastIndexOf("_" + vals[0]); - if (idx > -1) { - foundVariant = true; - - baseName = baseName.substring(0, idx); - if (baseName.endsWith("_")) { - baseName = baseName.substring(0, --idx); - } - parser.setBaseName(baseName); - parser.defaultKeywordValue(vals[1], vals[2]); - break; - } - } - /* See if this is an already known locale */ for (int i = 0; i < CANONICALIZE_MAP.length; i++) { - if (CANONICALIZE_MAP[i][0].equals(baseName)) { + String[] vals = CANONICALIZE_MAP[i]; + if (vals[0].equals(baseName)) { foundVariant = true; - String[] vals = CANONICALIZE_MAP[i]; parser.setBaseName(vals[1]); - if (vals[2] != null) { - parser.defaultKeywordValue(vals[2], vals[3]); - } break; } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java index 009613adf4..b8abc6c2be 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java @@ -95,7 +95,9 @@ public final class ICUResourceBundleCollationTest extends TestFmwk { ICUResourceBundle bundle = null; String key = null; try{ - bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUData.ICU_COLLATION_BASE_NAME,ULocale.canonicalize("de__PHONEBOOK")); + bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance( + ICUData.ICU_COLLATION_BASE_NAME, + ULocale.canonicalize("de@collation=phonebook")); if(!bundle.getULocale().getName().equals("de")){ errln("did not get the expected bundle"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java index 5b13c49473..03e6a0c746 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java @@ -1086,7 +1086,6 @@ public class IBMCalendarTest extends CalendarTestFmwk { "ja_JP@calendar=japanese", "th_TH@calendar=buddhist", "th-TH-u-ca-gregory", - "ja_JP_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH_TRADITIONAL@calendar=gregorian", "en_US", @@ -1109,7 +1108,6 @@ public class IBMCalendarTest extends CalendarTestFmwk { "japanese", "buddhist", "gregorian", - "japanese", "buddhist", "gregorian", "gregorian", diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java index bb951e8a00..570b283ce6 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java @@ -678,28 +678,28 @@ public class NumberFormatTest extends TestFmwk { @Test public void TestCurrency() { String[] DATA = { - "fr", "CA", "", "1,50\u00a0$", - "de", "DE", "", "1,50\u00a0\u20AC", - "de", "DE", "PREEURO", "1,50\u00a0DM", - "fr", "FR", "", "1,50\u00a0\u20AC", - "fr", "FR", "PREEURO", "1,50\u00a0F", + "fr_CA", "1,50\u00a0$", + "de_DE", "1,50\u00a0\u20AC", + "de_DE@currency=DEM", "1,50\u00a0DM", + "fr_FR", "1,50\u00a0\u20AC", + "fr_FR@currency=FRF", "1,50\u00a0F", }; - for (int i=0; i " + s); } else { logln("FAIL: 1.50 x " + locale + " => " + s + - ", expected " + DATA[i+3]); + ", expected " + DATA[i+1]); } } // format currency with CurrencyAmount - for (int i=0; i " + sCurr); } else { errln("FAIL: 1.50 x " + locale + " => " + sCurr + - ", expected " + DATA[i+3]); + ", expected " + DATA[i+1]); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java index 508e8faa5e..0e8de689b5 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java @@ -626,7 +626,6 @@ public class CurrencyTest extends TestFmwk { { "eo_DE@currency=DEM", "2000-12-23", "EUR", "DEM" }, { "eo-DE-u-cu-dem", "2000-12-23", "EUR", "DEM" }, { "en_US", null, "USD", "USN" }, - { "en_US_PREEURO", null, "USD", "USN" }, { "en_US_Q", null, "USD", "USN" }, }; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java index 26c419daa9..5b657c8f8e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -677,9 +677,6 @@ public class ULocaleTest extends TestFmwk { {"no", "", "", "NY", "no@ny", "no@ny", "no__NY"}, {"el", "Latn", "", "", "el-latn", "el_Latn", null}, {"en", "Cyrl", "RU", "", "en-cyrl-ru", "en_Cyrl_RU", null}, - {"zh", "Hant", "TW", "STROKE", "zh-hant_TW_STROKE", "zh_Hant_TW_STROKE", "zh_Hant_TW@collation=stroke"}, - {"zh", "Hant", "CN", "STROKE", "zh-hant_CN_STROKE", "zh_Hant_CN_STROKE", "zh_Hant_CN@collation=stroke"}, - {"zh", "Hant", "TW", "PINYIN", "zh-hant_TW_PINYIN", "zh_Hant_TW_PINYIN", "zh_Hant_TW@collation=pinyin"}, {"qq", "Qqqq", "QQ", "QQ", "qq_Qqqq_QQ_QQ", "qq_Qqqq_QQ_QQ", null}, {"qq", "Qqqq", "", "QQ", "qq_Qqqq__QQ", "qq_Qqqq__QQ", null}, {"ab", "Cdef", "GH", "IJ", "ab_cdef_gh_ij", "ab_Cdef_GH_IJ", null}, /* total garbage */ @@ -689,6 +686,13 @@ public class ULocaleTest extends TestFmwk { {"", "", "", "", "_@FOO=bar", "@foo=bar", null}, {"", "", "", "", "__@FOO=bar", "@foo=bar", null}, {"", "", "", "FOO", "__foo@FOO=bar", "__FOO@foo=bar", null}, // we have some of these prefixes + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now use standard canonicalization. + {"zh", "Hant", "TW", "STROKE", "zh-hant_TW_STROKE", "zh_Hant_TW_STROKE", "zh_Hant_TW_STROKE"}, + {"zh", "Hant", "CN", "STROKE", "zh-hant_CN_STROKE", "zh_Hant_CN_STROKE", "zh_Hant_CN_STROKE"}, + {"zh", "Hant", "TW", "PINYIN", "zh-hant_TW_PINYIN", "zh_Hant_TW_PINYIN", "zh_Hant_TW_PINYIN"}, }; String loc, buf,buf1; @@ -886,35 +890,6 @@ public class ULocaleTest extends TestFmwk { @Test public void TestCanonicalization(){ final String[][]testCases = new String[][]{ - { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" }, - { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" }, - { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" }, - { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=EUR" }, - { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" }, - { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" }, - { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" }, - { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" }, - { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" }, - { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" }, - { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" }, - { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" }, - { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" }, - { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" }, - { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" }, - { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" }, - { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" }, - { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" }, - { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" }, - { "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" }, - { "de_PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" }, - { "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" }, - { "en_GB@EURO", null, "en_GB@currency=EUR" }, /* POSIX ID */ - { "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" }, - { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" }, - { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" }, - { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" }, - { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" }, - { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" }, { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" }, { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" }, { "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" }, @@ -923,17 +898,9 @@ public class ULocaleTest extends TestFmwk { { "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ }, { "no@ny", null, "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */ { "no-no.utf32@B", null, "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */ - { "qz-qz@Euro", null, "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */ { "en-BOONT", "en__BOONT", "en__BOONT" }, /* registered name */ { "de-1901", "de__1901", "de__1901" }, /* registered name */ { "de-1906", "de__1906", "de__1906" }, /* registered name */ - { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */ - { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */ - { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */ - { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */ - { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */ - { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */ - { "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */ /* posix behavior that used to be performed by getName */ { "mr.utf8", null, "mr" }, @@ -948,6 +915,56 @@ public class ULocaleTest extends TestFmwk { { "en_Hant_IL_VALLEY_GIRL@currency=EUR;calendar=Japanese;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, /* already-canonical ids are not changed */ { "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" }, + /* norwegian is just too weird, if we handle things in their full generality */ + /* this is a negative test to show that we DO NOT handle 'lang=no,var=NY' specially. */ + { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ }, + + /* test cases reflecting internal resource bundle usage */ + /* root is just a language */ + { "root@kw=foo", "root@kw=foo", "root@kw=foo" }, + /* level 2 canonicalization should not touch basename when there are keywords and it is null */ + { "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" }, + + // Before ICU 64, ICU locale canonicalization had some additional mappings. + // They were removed for ICU-20187 "drop support for long-obsolete locale ID variants". + // The following now use standard canonicalization. + { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES_PREEURO" }, + { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT_PREEURO" }, + { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE_PREEURO" }, + { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU_PREEURO" }, + { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR_PREEURO" }, + { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE_PREEURO" }, + { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE_PREEURO" }, + { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES_PREEURO" }, + { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES_PREEURO" }, + { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI_PREEURO" }, + { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE_PREEURO" }, + { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR_PREEURO" }, + { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU_PREEURO" }, + { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE_PREEURO" }, + { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES_PREEURO" }, + { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT_PREEURO" }, + { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE_PREEURO" }, + { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL_PREEURO" }, + { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT_PREEURO" }, + { "de__PHONEBOOK", "de__PHONEBOOK", "de__PHONEBOOK" }, + { "de_PHONEBOOK", "de__PHONEBOOK", "de__PHONEBOOK" }, + { "en_GB_EURO", "en_GB_EURO", "en_GB_EURO" }, + { "en_GB@EURO", null, "en_GB_EURO" }, /* POSIX ID */ + { "es__TRADITIONAL", "es__TRADITIONAL", "es__TRADITIONAL" }, + { "hi__DIRECT", "hi__DIRECT", "hi__DIRECT" }, + { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL" }, + { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH_TRADITIONAL" }, + { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW_STROKE" }, + { "zh__PINYIN", "zh__PINYIN", "zh__PINYIN" }, + { "qz-qz@Euro", null, "qz_QZ_EURO" }, /* qz-qz uses private use iso codes */ + { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_SP_CYRL" }, /* .NET name */ + { "sr-SP-Latn", "sr_SP_LATN", "sr_SP_LATN" }, /* .NET name */ + { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_YU_CYRILLIC" }, /* Linux name */ + { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_UZ_CYRL" }, /* .NET name */ + { "uz-UZ-Latn", "uz_UZ_LATN", "uz_UZ_LATN" }, /* .NET name */ + { "zh-CHS", "zh_CHS", "zh_CHS" }, /* .NET name */ + { "zh-CHT", "zh_CHT", "zh_CHT" }, /* .NET name This may change back to zh_Hant */ /* PRE_EURO and EURO conversions don't affect other keywords */ /* not in spec { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" }, @@ -958,15 +975,6 @@ public class ULocaleTest extends TestFmwk { { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" }, { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" }, */ - /* norwegian is just too weird, if we handle things in their full generality */ - /* this is a negative test to show that we DO NOT handle 'lang=no,var=NY' specially. */ - { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ }, - - /* test cases reflecting internal resource bundle usage */ - /* root is just a language */ - { "root@kw=foo", "root@kw=foo", "root@kw=foo" }, - /* level 2 canonicalization should not touch basename when there are keywords and it is null */ - { "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" }, }; for(int i = 0; i< testCases.length;i++){ @@ -4325,7 +4333,7 @@ public class ULocaleTest extends TestFmwk { for (String[] testcase : TESTCASES) { ULocale loc = ULocale.forLanguageTag(testcase[0]); - Set expectedAttributes = new HashSet(); + Set expectedAttributes = new HashSet<>(); if (testcase[1] != null) { String[] attrs = testcase[1].split(","); for (String s : attrs) { @@ -4333,7 +4341,7 @@ public class ULocaleTest extends TestFmwk { } } - Map expectedKeywords = new HashMap(); + Map expectedKeywords = new HashMap<>(); if (testcase[2] != null) { String[] ukeys = testcase[2].split(","); for (int i = 0; i < ukeys.length; i++) { @@ -4665,7 +4673,7 @@ public class ULocaleTest extends TestFmwk { "zh_Hant_TW", }; - TreeSet sortedLocales = new TreeSet(); + TreeSet sortedLocales = new TreeSet<>(); for (ULocale locale : locales) { sortedLocales.add(locale); }