1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 4 ******************************************************************************** 5 * Copyright (C) 1997-2016, International Business Machines 6 * Corporation and others. All Rights Reserved. 7 ******************************************************************************** 11 * Modification History: 13 * Date Name Description 14 * 02/19/97 aliu Converted from java. 15 * 03/18/97 clhuang Updated per C++ implementation. 16 * 03/27/97 helena Updated to pass the simple test after code review. 17 * 08/26/97 aliu Added currency/intl currency symbol support. 18 * 07/22/98 stephen Changed to match C++ style 19 * currencySymbol -> fCurrencySymbol 20 * Constants changed from CAPS to kCaps 21 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes 22 * 09/22/00 grhoten Marked deprecation tags with a pointer to replacement 24 ******************************************************************************** 32 #if U_SHOW_CPLUSPLUS_API 34 #if !UCONFIG_NO_FORMATTING 173 #ifndef U_HIDE_INTERNAL_API 178 #endif/* U_HIDE_INTERNAL_API */ 180 kFormatSymbolCount = kExponentMultiplicationSymbol + 2
285 inlineUnicodeString getSymbol(ENumberFormatSymbol symbol)
const;
299 void setSymbol(ENumberFormatSymbol symbol,
constUnicodeString &value,
constUBool propagateDigits);
301 #ifndef U_HIDE_INTERNAL_API 310 #endif// U_HIDE_INTERNAL_API 316 inlineLocale getLocale()
const;
342 UBool beforeCurrency,
355 UBool beforeCurrency,
397 #ifndef U_HIDE_INTERNAL_API 402 return fIsCustomCurrencySymbol;
409 return fIsCustomIntlCurrencySymbol;
416 return fCodePointZero;
418 #endif/* U_HIDE_INTERNAL_API */ 435 inlineconstUnicodeString& getConstSymbol(ENumberFormatSymbol symbol)
const;
437 #ifndef U_HIDE_INTERNAL_API 453 inlineconstUnicodeString& getConstDigitSymbol(int32_t digit)
const;
459 inlineconst char16_t* getCurrencyPattern()
const;
465 inlineconstchar* getNumberingSystemName()
const;
466 #endif/* U_HIDE_INTERNAL_API */ 508 CharString* actualLocale =
nullptr;
509 CharString* validLocale =
nullptr;
510 const char16_t* currPattern =
nullptr;
514 UBool fIsCustomCurrencySymbol;
515 UBool fIsCustomIntlCurrencySymbol;
519 // ------------------------------------- 524 if(symbol < kFormatSymbolCount) {
525 strPtr = &fSymbols[symbol];
532 // See comments above for this function. Not hidden with #ifdef U_HIDE_INTERNAL_API 536 if(symbol < kFormatSymbolCount) {
537 strPtr = &fSymbols[symbol];
544 #ifndef U_HIDE_INTERNAL_API 545 inlineconstUnicodeString& DecimalFormatSymbols::getConstDigitSymbol(int32_t digit)
const{
546 if (digit < 0 || digit > 9) {
550 return fSymbols[kZeroDigitSymbol];
553 return fSymbols[key];
555 #endif/* U_HIDE_INTERNAL_API */ 557 // ------------------------------------- 561 if (symbol == kCurrencySymbol) {
562 fIsCustomCurrencySymbol =
true;
564 elseif (symbol == kIntlCurrencySymbol) {
565 fIsCustomIntlCurrencySymbol =
true;
567 if(symbol<kFormatSymbolCount) {
568 fSymbols[symbol]=value;
571 // If the zero digit is being set to a known zero digit according to Unicode, 572 // then we automatically set the corresponding 1-9 digits 573 // Also record updates to fCodePointZero. Be conservative if in doubt. 574 if (symbol == kZeroDigitSymbol) {
577 fCodePointZero = sym;
578 for ( int8_t i = 1 ; i<= 9 ; i++ ) {
580 fSymbols[
static_cast<int>(kOneDigitSymbol) + i - 1] =
UnicodeString(sym);
585 }
elseif (symbol >= kOneDigitSymbol && symbol <= kNineDigitSymbol) {
590 // ------------------------------------- 593 DecimalFormatSymbols::getLocale()
const{
597 #ifndef U_HIDE_INTERNAL_API 598 inlineconst char16_t*
599 DecimalFormatSymbols::getCurrencyPattern()
const{
603 DecimalFormatSymbols::getNumberingSystemName()
const{
606 #endif/* U_HIDE_INTERNAL_API */ 610 #endif/* #if !UCONFIG_NO_FORMATTING */ 612 #endif/* U_SHOW_CPLUSPLUS_API */ This class represents the set of symbols needed by DecimalFormat to format numbers.
void setPatternForCurrencySpacing(UCurrencySpacing type, UBool beforeCurrency, const UnicodeString &pattern)
Set pattern string for 'CurrencySpacing' that can be applied to currency format.
UBool isCustomCurrencySymbol() const
bool operator==(const DecimalFormatSymbols &other) const
Return true if another object is semantically equal to this one.
virtual ~DecimalFormatSymbols()
Destructor.
const UnicodeString & getPatternForCurrencySpacing(UCurrencySpacing type, UBool beforeCurrency, UErrorCode &status) const
Get pattern string for 'CurrencySpacing' that can be applied to currency format.
ENumberFormatSymbol
Constants for specifying a number format symbol.
@ kEightDigitSymbol
Eight.
@ kThreeDigitSymbol
Three.
@ kDecimalSeparatorSymbol
The decimal separator.
@ kPlusSignSymbol
The plus sign.
@ kMinusSignSymbol
The minus sign.
@ kExponentMultiplicationSymbol
Multiplication sign.
@ kInfinitySymbol
Infinity symbol.
@ kExponentialSymbol
The exponential symbol.
@ kPerMillSymbol
Per mill symbol - replaces kPermillSymbol.
@ kPatternSeparatorSymbol
The pattern separator.
@ kCurrencySymbol
The currency symbol.
@ kSignificantDigitSymbol
Significant digit symbol.
@ kIntlCurrencySymbol
The international currency symbol.
@ kMonetaryGroupingSeparatorSymbol
The monetary grouping separator.
@ kSevenDigitSymbol
Seven.
@ kPadEscapeSymbol
Escape padding character.
@ kPercentSymbol
The percent sign.
@ kApproximatelySignSymbol
Approximately sign.
@ kDigitSymbol
Character representing a digit in the pattern.
@ kMonetarySeparatorSymbol
The monetary separator.
@ kGroupingSeparatorSymbol
The grouping separator.
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
DecimalFormatSymbols(UErrorCode &status)
Create a DecimalFormatSymbols object for the default locale.
DecimalFormatSymbols(const Locale &locale, UErrorCode &status)
Create a DecimalFormatSymbols object for the given locale.
void setCurrency(const char16_t *currency, UErrorCode &status)
Loads symbols for the specified currency into this instance.
DecimalFormatSymbols(const DecimalFormatSymbols &)
Copy constructor.
bool operator!=(const DecimalFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
static DecimalFormatSymbols * createWithLastResortData(UErrorCode &status)
Creates a DecimalFormatSymbols object with last-resort data.
UChar32 getCodePointZero() const
DecimalFormatSymbols & operator=(const DecimalFormatSymbols &)
Assignment operator.
DecimalFormatSymbols(const Locale &locale, const NumberingSystem &ns, UErrorCode &status)
Creates a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to...
UBool isCustomIntlCurrencySymbol() const
A Locale object represents a specific geographical, political, or cultural region.
Defines numbering systems.
UObject is the common ICU "boilerplate" class.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
UChar32 char32At(int32_t offset) const
Return the code point that contains the code unit at offset offset.
int32_t countChar32(int32_t start=0, int32_t length=INT32_MAX) const
Count Unicode code points in the length char16_t code units of the string.
C++ API: Locale ID object.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
constexpr const size_t kInternalNumSysNameCapacity
Size of a numbering system name.
C++ API: NumberingSystem object.
C API: Unicode Properties.
U_CAPI int32_t u_charDigitValue(UChar32 c)
Returns the decimal digit value of a decimal digit character.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
int8_t UBool
The ICU boolean type, a signed-byte integer.
C API: Compatibility APIs for number formatting.
UCurrencySpacing
Constants for specifying currency spacing.
@ UNUM_CURRENCY_SPACING_COUNT
One more than the highest normal UCurrencySpacing value.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.