diff --git a/icu4c/source/common/locdispnames.cpp b/icu4c/source/common/locdispnames.cpp index f9427e87c8a..cc6340c29da 100644 --- a/icu4c/source/common/locdispnames.cpp +++ b/icu4c/source/common/locdispnames.cpp @@ -427,285 +427,6 @@ uloc_getDisplayVariant(const char *locale, uloc_getVariant, _kVariants, pErrorCode); } -/* TODO:dougfelt remove */ -U_CAPI int32_t U_EXPORT2 -uloc_getDisplayNameOld(const char *locale, - const char *displayLocale, - UChar *dest, int32_t destCapacity, - UErrorCode *pErrorCode) -{ - int32_t length, length2, length3 = 0; - UBool hasLanguage, hasScript, hasCountry, hasVariant, hasKeywords; - UEnumeration* keywordEnum = NULL; - int32_t keywordCount = 0; - const char *keyword = NULL; - int32_t keywordLen = 0; - char keywordValue[256]; - int32_t keywordValueLen = 0; - - int32_t locSepLen = 0; - int32_t locPatLen = 0; - int32_t p0Len = 0; - int32_t defaultPatternLen = 9; - const UChar *dispLocSeparator; - const UChar *dispLocPattern; - static const UChar defaultSeparator[3] = { 0x002c, 0x0020 , 0x0000 }; /* comma + space */ - static const UChar defaultPattern[10] = { 0x007b, 0x0030, 0x007d, 0x0020, 0x0028, 0x007b, 0x0031, 0x007d, 0x0029, 0x0000 }; /* {0} ({1}) */ - static const UChar pat0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 } ; /* {0} */ - static const UChar pat1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 } ; /* {1} */ - - UResourceBundle *bundle = NULL; - UResourceBundle *locdsppat = NULL; - - UErrorCode status = U_ZERO_ERROR; - - /* argument checking */ - if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { - return 0; - } - - if(destCapacity<0 || (destCapacity>0 && dest==NULL)) { - *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - - bundle = ures_open(U_ICUDATA_LANG, displayLocale, &status); - - locdsppat = ures_getByKeyWithFallback(bundle, _kLocaleDisplayPattern, NULL, &status); - dispLocSeparator = ures_getStringByKeyWithFallback(locdsppat, _kSeparator, &locSepLen, &status); - dispLocPattern = ures_getStringByKeyWithFallback(locdsppat, _kPattern, &locPatLen, &status); - - /*close the bundles */ - ures_close(locdsppat); - ures_close(bundle); - - /* If we couldn't find any data, then use the defaults */ - if ( locSepLen == 0) { - dispLocSeparator = defaultSeparator; - locSepLen = 2; - } - - if ( locPatLen == 0) { - dispLocPattern = defaultPattern; - locPatLen = 9; - } - - /* - * if there is a language, then write "language (country, variant)" - * otherwise write "country, variant" - */ - - /* write the language */ - length=uloc_getDisplayLanguage(locale, displayLocale, - dest, destCapacity, - pErrorCode); - hasLanguage= length>0; - - if(hasLanguage) { - p0Len = length; - - /* append " (" */ - if(length0; - length+=length2; - - if(hasScript) { - /* append separator */ - if(length+locSepLen<=destCapacity) { - u_memcpy(dest+length,dispLocSeparator,locSepLen); - } - length+=locSepLen; - } - - if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR) { - /* keep preflighting */ - *pErrorCode=U_ZERO_ERROR; - } - - /* append the country */ - if(length0; - length+=length2; - - if(hasCountry) { - /* append separator */ - if(length+locSepLen<=destCapacity) { - u_memcpy(dest+length,dispLocSeparator,locSepLen); - } - length+=locSepLen; - } - - if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR) { - /* keep preflighting */ - *pErrorCode=U_ZERO_ERROR; - } - - /* append the variant */ - if(length0; - length+=length2; - - if(hasVariant) { - /* append separator */ - if(length+locSepLen<=destCapacity) { - u_memcpy(dest+length,dispLocSeparator,locSepLen); - } - length+=locSepLen; - } - - keywordEnum = uloc_openKeywords(locale, pErrorCode); - - for(keywordCount = uenum_count(keywordEnum, pErrorCode); keywordCount > 0 ; keywordCount--){ - if(U_FAILURE(*pErrorCode)){ - break; - } - /* the uenum_next returns NUL terminated string */ - keyword = uenum_next(keywordEnum, &keywordLen, pErrorCode); - if(length + length3 < destCapacity) { - length3 += uloc_getDisplayKeyword(keyword, displayLocale, dest+length+length3, destCapacity-length-length3, pErrorCode); - } else { - length3 += uloc_getDisplayKeyword(keyword, displayLocale, NULL, 0, pErrorCode); - } - if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR) { - /* keep preflighting */ - *pErrorCode=U_ZERO_ERROR; - } - keywordValueLen = uloc_getKeywordValue(locale, keyword, keywordValue, 256, pErrorCode); - if(keywordValueLen) { - if(length + length3 < destCapacity) { - dest[length + length3] = 0x3D; - } - length3++; - if(length + length3 < destCapacity) { - length3 += uloc_getDisplayKeywordValue(locale, keyword, displayLocale, dest+length+length3, destCapacity-length-length3, pErrorCode); - } else { - length3 += uloc_getDisplayKeywordValue(locale, keyword, displayLocale, NULL, 0, pErrorCode); - } - if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR) { - /* keep preflighting */ - *pErrorCode=U_ZERO_ERROR; - } - } - if(keywordCount > 1) { - if(length + length3 + locSepLen <= destCapacity && keywordCount) { - u_memcpy(dest+length+length3,dispLocSeparator,locSepLen); - length3+=locSepLen; - } - } - } - uenum_close(keywordEnum); - - hasKeywords = length3 > 0; - length += length3; - - - if ((hasScript && !hasCountry) - || ((hasScript || hasCountry) && !hasVariant && !hasKeywords) - || ((hasScript || hasCountry || hasVariant) && !hasKeywords)) { - /* Remove separator */ - length -= locSepLen; - } else if (hasLanguage && !hasScript && !hasCountry && !hasVariant && !hasKeywords) { - /* Remove " (" */ - length-=2; - } - - if (hasLanguage && (hasScript || hasCountry || hasVariant || hasKeywords)) { - /* append ")" */ - if(length