ICU 76.1 76.1
|
This class represents the set of symbols needed by DecimalFormat to format numbers. More...
#include <dcfmtsym.h>
Public Types | |
enum | ENumberFormatSymbol { kDecimalSeparatorSymbol , kGroupingSeparatorSymbol , kPatternSeparatorSymbol , kPercentSymbol , kZeroDigitSymbol , kDigitSymbol , kMinusSignSymbol , kPlusSignSymbol , kCurrencySymbol , kIntlCurrencySymbol , kMonetarySeparatorSymbol , kExponentialSymbol , kPerMillSymbol , kPadEscapeSymbol , kInfinitySymbol , kNaNSymbol , kSignificantDigitSymbol , kMonetaryGroupingSeparatorSymbol , kOneDigitSymbol , kTwoDigitSymbol , kThreeDigitSymbol , kFourDigitSymbol , kFiveDigitSymbol , kSixDigitSymbol , kSevenDigitSymbol , kEightDigitSymbol , kNineDigitSymbol , kExponentMultiplicationSymbol , kApproximatelySignSymbol , kFormatSymbolCount = kExponentMultiplicationSymbol + 2 } |
Constants for specifying a number format symbol. More... | |
Public Member Functions | |
DecimalFormatSymbols (const Locale &locale, UErrorCode &status) | |
Create a DecimalFormatSymbols object for the given locale. | |
DecimalFormatSymbols (const Locale &locale, const NumberingSystem &ns, UErrorCode &status) | |
Creates a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the given NumberingSystem. | |
DecimalFormatSymbols (UErrorCode &status) | |
Create a DecimalFormatSymbols object for the default locale. | |
DecimalFormatSymbols (const DecimalFormatSymbols &) | |
Copy constructor. | |
DecimalFormatSymbols & | operator= (const DecimalFormatSymbols &) |
Assignment operator. | |
virtual | ~DecimalFormatSymbols () |
Destructor. | |
bool | operator== (const DecimalFormatSymbols &other) const |
Return true if another object is semantically equal to this one. | |
bool | operator!= (const DecimalFormatSymbols &other) const |
Return true if another object is semantically unequal to this one. | |
UnicodeString | getSymbol (ENumberFormatSymbol symbol) const |
Get one of the format symbols by its enum constant. | |
void | setSymbol (ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propagateDigits) |
Set one of the format symbols by its enum constant. | |
void | setCurrency (const char16_t *currency, UErrorCode &status) |
Loads symbols for the specified currency into this instance. | |
Locale | getLocale () const |
Returns the locale for which this object was constructed. | |
Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const |
Returns the locale for this object. | |
const UnicodeString & | getPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, UErrorCode &status) const |
Get pattern string for 'CurrencySpacing' that can be applied to currency format. | |
void | setPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, const UnicodeString &pattern) |
Set pattern string for 'CurrencySpacing' that can be applied to currency format. | |
virtual UClassID | getDynamicClassID () const override |
ICU "poor man's RTTI", returns a UClassID for the actual class. | |
UBool | isCustomCurrencySymbol () const |
UBool | isCustomIntlCurrencySymbol () const |
UChar32 | getCodePointZero () const |
const UnicodeString & | getConstSymbol (ENumberFormatSymbol symbol) const |
Internal function - more efficient version of getSymbol, returning a const reference to one of the symbol strings. | |
const UnicodeString & | getConstDigitSymbol (int32_t digit) const |
Returns the const UnicodeString reference, like getConstSymbol, corresponding to the digit with the given value. | |
const char16_t * | getCurrencyPattern () const |
Returns that pattern stored in currency info. | |
const char * | getNumberingSystemName () const |
Returns the numbering system with which this DecimalFormatSymbols was initialized. | |
Public Member Functions inherited from icu::UObject | |
virtual | ~UObject () |
Destructor. | |
Static Public Member Functions | |
static DecimalFormatSymbols * | createWithLastResortData (UErrorCode &status) |
Creates a DecimalFormatSymbols object with last-resort data. | |
static UClassID | getStaticClassID () |
ICU "poor man's RTTI", returns a UClassID for this class. | |
This class represents the set of symbols needed by DecimalFormat to format numbers.
DecimalFormat creates for itself an instance of DecimalFormatSymbols from its locale data. If you need to change any of these symbols, you can get the DecimalFormatSymbols object from your DecimalFormat and modify it.
Here are the special characters used in the parts of the subpattern, with notes on their usage.
0 a digit# a digit, zero shows as absent' used to quote special characters in a prefix or suffix."Smart pointer" base class; do not use directly: use LocalPointer etc.Definition localpointer.h:68
[Notes]
If there is no explicit negative subpattern, - is prefixed to the positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".
The grouping separator is commonly used for thousands, but in some countries for ten-thousands. The interval is a constant number of digits between the grouping characters, such as 100,000,000 or 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".
Definition at line 86 of file dcfmtsym.h.
Constants for specifying a number format symbol.
Enumerator | |
---|---|
kDecimalSeparatorSymbol | The decimal separator. |
kGroupingSeparatorSymbol | The grouping separator. |
kPatternSeparatorSymbol | The pattern separator. |
kPercentSymbol | The percent sign. |
kZeroDigitSymbol | Zero. |
kDigitSymbol | Character representing a digit in the pattern. |
kMinusSignSymbol | The minus sign. |
kPlusSignSymbol | The plus sign. |
kCurrencySymbol | The currency symbol. |
kIntlCurrencySymbol | The international currency symbol. |
kMonetarySeparatorSymbol | The monetary separator. |
kExponentialSymbol | The exponential symbol. |
kPerMillSymbol | Per mill symbol - replaces kPermillSymbol. |
kPadEscapeSymbol | Escape padding character. |
kInfinitySymbol | Infinity symbol. |
kNaNSymbol | Nan symbol. |
kSignificantDigitSymbol | Significant digit symbol.
|
kMonetaryGroupingSeparatorSymbol | The monetary grouping separator.
|
kOneDigitSymbol | One.
|
kTwoDigitSymbol | Two.
|
kThreeDigitSymbol | Three.
|
kFourDigitSymbol | Four.
|
kFiveDigitSymbol | Five.
|
kSixDigitSymbol | Six.
|
kSevenDigitSymbol | Seven.
|
kEightDigitSymbol | Eight.
|
kNineDigitSymbol | Nine.
|
kExponentMultiplicationSymbol | Multiplication sign.
|
kApproximatelySignSymbol | Approximately sign.
|
kFormatSymbolCount | count symbol constants |
Definition at line 92 of file dcfmtsym.h.
icu::DecimalFormatSymbols::DecimalFormatSymbols | ( | const Locale & | locale, |
UErrorCode & | status | ||
) |
Create a DecimalFormatSymbols object for the given locale.
locale | The locale to get symbols for. |
status | Input/output parameter, set to success or failure code upon return. |
icu::DecimalFormatSymbols::DecimalFormatSymbols | ( | const Locale & | locale, |
const NumberingSystem & | ns, | ||
UErrorCode & | status | ||
) |
Creates a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the given NumberingSystem.
This constructor behaves equivalently to the normal constructor called with a locale having a "numbers=xxxx" keyword specifying the numbering system by name.
In this constructor, the NumberingSystem argument will be used even if the locale has its own "numbers=xxxx" keyword.
locale | The locale to get symbols for. |
ns | The numbering system. |
status | Input/output parameter, set to success or failure code upon return. |
icu::DecimalFormatSymbols::DecimalFormatSymbols | ( | UErrorCode & | status | ) |
Create a DecimalFormatSymbols object for the default locale.
This constructor will not fail. If the resource file data is not available, it will use hard-coded last-resort data and set status to U_USING_FALLBACK_ERROR.
status | Input/output parameter, set to success or failure code upon return. |
icu::DecimalFormatSymbols::DecimalFormatSymbols | ( | const DecimalFormatSymbols & | ) |
Copy constructor.
|
static |
Creates a DecimalFormatSymbols object with last-resort data.
Intended for callers who cache the symbols data and set all symbols on the resulting object.
The last-resort symbols are similar to those for the root data, except that the grouping separators are empty, the NaN symbol is U+FFFD rather than "NaN", and the CurrencySpacing patterns are empty.
status | Input/output parameter, set to success or failure code upon return. |
|
inline |
Definition at line 414 of file dcfmtsym.h.
|
inline |
Returns the const UnicodeString reference, like getConstSymbol, corresponding to the digit with the given value.
This is equivalent to accessing the symbol from getConstSymbol with the corresponding key, such as kZeroDigitSymbol or kOneDigitSymbol.
This is not currently stable API, but if you think it should be stable, post a comment on the following ticket and the ICU team will take a look: https://unicode-org.atlassian.net/browse/ICU-13580
digit | The digit, an integer between 0 and 9 inclusive. If outside the range 0 to 9, the zero digit is returned. |
Definition at line 544 of file dcfmtsym.h.
|
inline |
Internal function - more efficient version of getSymbol, returning a const reference to one of the symbol strings.
The returned reference becomes invalid when the symbol is changed or when the DecimalFormatSymbols are destroyed. Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat
This is not currently stable API, but if you think it should be stable, post a comment on the following ticket and the ICU team will take a look: https://unicode-org.atlassian.net/browse/ICU-13580
symbol | Constant to indicate a number format symbol. |
Definition at line 533 of file dcfmtsym.h.
Returns that pattern stored in currency info.
Internal API for use by NumberFormat API.
Definition at line 598 of file dcfmtsym.h.
ICU "poor man's RTTI", returns a UClassID for the actual class.
Reimplemented from icu::UObject.
|
inline |
Returns the locale for which this object was constructed.
Definition at line 592 of file dcfmtsym.h.
Locale icu::DecimalFormatSymbols::getLocale | ( | ULocDataLocaleType | type, |
UErrorCode & | status | ||
) | const |
Returns the locale for this object.
Two flavors are available: valid and actual locale.
Returns the numbering system with which this DecimalFormatSymbols was initialized.
Definition at line 602 of file dcfmtsym.h.
const UnicodeString & icu::DecimalFormatSymbols::getPatternForCurrencySpacing | ( | UCurrencySpacing | type, |
UBool | beforeCurrency, | ||
UErrorCode & | status | ||
) | const |
Get pattern string for 'CurrencySpacing' that can be applied to currency format.
This API gets the CurrencySpacing data from ResourceBundle. The pattern can be empty if there is no data from current locale and its parent locales.
type | : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT. |
beforeCurrency | : true if the pattern is for before currency symbol. false if the pattern is for after currency symbol. |
status | Input/output parameter, set to success or failure code upon return. |
ICU "poor man's RTTI", returns a UClassID for this class.
|
inline |
Get one of the format symbols by its enum constant.
Each symbol is stored as a string so that graphemes (characters with modifier letters) can be used.
symbol | Constant to indicate a number format symbol. |
Definition at line 521 of file dcfmtsym.h.
|
inline |
Definition at line 400 of file dcfmtsym.h.
|
inline |
Definition at line 407 of file dcfmtsym.h.
|
inline |
Return true if another object is semantically unequal to this one.
other | the object to be compared with. |
Definition at line 273 of file dcfmtsym.h.
References icu::operator==().
DecimalFormatSymbols & icu::DecimalFormatSymbols::operator= | ( | const DecimalFormatSymbols & | ) |
Assignment operator.
bool icu::DecimalFormatSymbols::operator== | ( | const DecimalFormatSymbols & | other | ) | const |
Return true if another object is semantically equal to this one.
other | the object to be compared with. |
void icu::DecimalFormatSymbols::setCurrency | ( | const char16_t * | currency, |
UErrorCode & | status | ||
) |
Loads symbols for the specified currency into this instance.
This method is internal. If you think it should be public, file a ticket.
void icu::DecimalFormatSymbols::setPatternForCurrencySpacing | ( | UCurrencySpacing | type, |
UBool | beforeCurrency, | ||
const UnicodeString & | pattern | ||
) |
Set pattern string for 'CurrencySpacing' that can be applied to currency format.
type | : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT. |
beforeCurrency | : true if the pattern is for before currency symbol. false if the pattern is for after currency symbol. |
pattern | : pattern string to override current setting. |
|
inline |
Set one of the format symbols by its enum constant.
Each symbol is stored as a string so that graphemes (characters with modifier letters) can be used.
symbol | Constant to indicate a number format symbol. |
value | value of the format symbol |
propagateDigits | If false, setting the zero digit will not automatically set 1-9. The default behavior is to automatically set 1-9 if zero is being set and the value it is being set to corresponds to a known Unicode zero digit. |
Definition at line 559 of file dcfmtsym.h.
References icu::UnicodeString::char32At(), icu::UnicodeString::countChar32(), and u_charDigitValue().