- /* else use the default values. */
-
- U_LOCALE_BASED(locBased, *this);
- locBased.setLocaleIDs(ures_getLocaleByType(numberElementsRes,
- ULOC_VALID_LOCALE, &status),
- ures_getLocaleByType(numberElementsRes,
- ULOC_ACTUAL_LOCALE, &status));
-
- //load the currency data
- UChar ucc[4]={0}; //Currency Codes are always 3 chars long
- int32_t uccLen = 4;
- const char* locName = loc.getName();
- UErrorCode localStatus = U_ZERO_ERROR;
- uccLen = ucurr_forLocale(locName, ucc, uccLen, &localStatus);
-
- if(U_SUCCESS(localStatus) && uccLen > 0) {
- char cc[4]={0};
- u_UCharsToChars(ucc, cc, uccLen);
- /* An explicit currency was requested */
- UResourceBundle *currencyResource = ures_open(U_ICUDATA_CURR, locStr, &localStatus);
- UResourceBundle *currency = ures_getByKeyWithFallback(currencyResource, "Currencies", NULL, &localStatus);
- currency = ures_getByKeyWithFallback(currency, cc, currency, &localStatus);
- if(U_SUCCESS(localStatus) && ures_getSize(currency)>2) { // the length is 3 if more data is present
- currency = ures_getByIndex(currency, 2, currency, &localStatus);
- int32_t currPatternLen = 0;
- currPattern = ures_getStringByIndex(currency, (int32_t)0, &currPatternLen, &localStatus);
- UnicodeString decimalSep = ures_getUnicodeStringByIndex(currency, (int32_t)1, &localStatus);
- UnicodeString groupingSep = ures_getUnicodeStringByIndex(currency, (int32_t)2, &localStatus);
- if(U_SUCCESS(localStatus)){
- fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
- fSymbols[kMonetarySeparatorSymbol] = decimalSep;
- //pattern.setTo(TRUE, currPattern, currPatternLen);
- status = localStatus;
- }
- }
- ures_close(currency);
- ures_close(currencyResource);
- /* else An explicit currency was requested and is unknown or locale data is malformed. */
- /* ucurr_* API will get the correct value later on. */
- }
- // else ignore the error if no currency
-
- // Currency Spacing.
- localStatus = U_ZERO_ERROR;
- UResourceBundle *currencyResource = ures_open(U_ICUDATA_CURR, locStr, &localStatus);
- UResourceBundle *currencySpcRes = ures_getByKeyWithFallback(currencyResource,
- gCurrencySpacingTag, NULL, &localStatus);
-
- if (localStatus == U_USING_FALLBACK_WARNING || U_SUCCESS(localStatus)) {
- const char* keywords[UNUM_CURRENCY_SPACING_COUNT] = {
- gCurrencyMatchTag, gCurrencySudMatchTag, gCurrencyInsertBtnTag
- };
- localStatus = U_ZERO_ERROR;
- UResourceBundle *dataRes = ures_getByKeyWithFallback(currencySpcRes,
- gBeforeCurrencyTag, NULL, &localStatus);
- if (localStatus == U_USING_FALLBACK_WARNING || U_SUCCESS(localStatus)) {
- localStatus = U_ZERO_ERROR;
- for (int32_t i = 0; i < UNUM_CURRENCY_SPACING_COUNT; i++) {
- currencySpcBeforeSym[i] = ures_getUnicodeStringByKey(dataRes, keywords[i], &localStatus);
- }
- ures_close(dataRes);
- }
- dataRes = ures_getByKeyWithFallback(currencySpcRes,
- gAfterCurrencyTag, NULL, &localStatus);
- if (localStatus == U_USING_FALLBACK_WARNING || U_SUCCESS(localStatus)) {
- localStatus = U_ZERO_ERROR;
- for (int32_t i = 0; i < UNUM_CURRENCY_SPACING_COUNT; i++) {
- currencySpcAfterSym[i] = ures_getUnicodeStringByKey(dataRes, keywords[i], &localStatus);
- }
- ures_close(dataRes);
+ }
+ /* else use the default values. */
+
+ //load the currency data
+ UChar ucc[4]={0}; //Currency Codes are always 3 chars long
+ int32_t uccLen = 4;
+ const char* locName = loc.getName();
+ UErrorCode localStatus = U_ZERO_ERROR;
+ uccLen = ucurr_forLocale(locName, ucc, uccLen, &localStatus);
+
+ // TODO: Currency pattern data loading is duplicated in number_formatimpl.cpp
+ if(U_SUCCESS(localStatus) && uccLen > 0) {
+ char cc[4]={0};
+ u_UCharsToChars(ucc, cc, uccLen);
+ /* An explicit currency was requested */
+ LocalUResourceBundlePointer currencyResource(ures_open(U_ICUDATA_CURR, locStr, &localStatus));
+ LocalUResourceBundlePointer currency(
+ ures_getByKeyWithFallback(currencyResource.getAlias(), "Currencies", NULL, &localStatus));
+ ures_getByKeyWithFallback(currency.getAlias(), cc, currency.getAlias(), &localStatus);
+ if(U_SUCCESS(localStatus) && ures_getSize(currency.getAlias())>2) { // the length is 3 if more data is present
+ ures_getByIndex(currency.getAlias(), 2, currency.getAlias(), &localStatus);
+ int32_t currPatternLen = 0;
+ currPattern =
+ ures_getStringByIndex(currency.getAlias(), (int32_t)0, &currPatternLen, &localStatus);
+ UnicodeString decimalSep =
+ ures_getUnicodeStringByIndex(currency.getAlias(), (int32_t)1, &localStatus);
+ UnicodeString groupingSep =
+ ures_getUnicodeStringByIndex(currency.getAlias(), (int32_t)2, &localStatus);
+ if(U_SUCCESS(localStatus)){
+ fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
+ fSymbols[kMonetarySeparatorSymbol] = decimalSep;
+ //pattern.setTo(TRUE, currPattern, currPatternLen);
+ status = localStatus;