// Allow implicit conversion from char16_t* to UnicodeString for this file: // Helpful in toString methods and elsewhere. #define UNISTR_FROM_STRING_EXPLICIT
CurrencySymbols::CurrencySymbols(CurrencyUnit currency, const Locale& locale, const DecimalFormatSymbols& symbols, UErrorCode& status)
: CurrencySymbols(currency, locale, status) { // If either of the overrides is present, save it in the local UnicodeString. if (symbols.isCustomCurrencySymbol()) {
fCurrencySymbol = symbols.getConstSymbol(DecimalFormatSymbols::kCurrencySymbol);
} if (symbols.isCustomIntlCurrencySymbol()) {
fIntlCurrencySymbol = symbols.getConstSymbol(DecimalFormatSymbols::kIntlCurrencySymbol);
}
}
UnicodeString CurrencySymbols::getNarrowCurrencySymbol(UErrorCode& status) const { // Note: currently no override is available for narrow currency symbol return loadSymbol(UCURR_NARROW_SYMBOL_NAME, status);
}
UnicodeString CurrencySymbols::getFormalCurrencySymbol(UErrorCode& status) const { // Note: currently no override is available for formal currency symbol return loadSymbol(UCURR_FORMAL_SYMBOL_NAME, status);
}
UnicodeString CurrencySymbols::getVariantCurrencySymbol(UErrorCode& status) const { // Note: currently no override is available for variant currency symbol return loadSymbol(UCURR_VARIANT_SYMBOL_NAME, status);
}
UnicodeString CurrencySymbols::loadSymbol(UCurrNameStyle selector, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency();
int32_t symbolLen = 0; const char16_t* symbol = ucurr_getName(
isoCode,
fLocaleName.data(),
selector,
nullptr /* isChoiceFormat */,
&symbolLen,
&status); // If given an unknown currency, ucurr_getName returns the input string, which we can't alias safely! // Otherwise, symbol points to a resource bundle, and we can use readonly-aliasing constructor. if (symbol == isoCode) { return UnicodeString(isoCode, 3);
} else { return UnicodeString(true, symbol, symbolLen);
}
}
UnicodeString CurrencySymbols::getIntlCurrencySymbol(UErrorCode&) const { if (!fIntlCurrencySymbol.isBogus()) { return fIntlCurrencySymbol;
} // Note: Not safe to use readonly-aliasing constructor here because the buffer belongs to this object, // which could be destructed or moved during the lifetime of the return value. return UnicodeString(fCurrency.getISOCurrency(), 3);
}
UnicodeString CurrencySymbols::getPluralName(StandardPlural::Form plural, UErrorCode& status) const { const char16_t* isoCode = fCurrency.getISOCurrency();
int32_t symbolLen = 0; const char16_t* symbol = ucurr_getPluralName(
isoCode,
fLocaleName.data(),
nullptr /* isChoiceFormat */,
StandardPlural::getKeyword(plural),
&symbolLen,
&status); // If given an unknown currency, ucurr_getName returns the input string, which we can't alias safely! // Otherwise, symbol points to a resource bundle, and we can use readonly-aliasing constructor. if (symbol == isoCode) { return UnicodeString(isoCode, 3);
} else { return UnicodeString(true, symbol, symbolLen);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.