ICU 64.2  64.2
Public Types | Public Member Functions | Static Public Member Functions
icu::DecimalFormatSymbols Class Reference

This class represents the set of symbols needed by DecimalFormat to format numbers. More...

#include <dcfmtsym.h>

Inheritance diagram for icu::DecimalFormatSymbols:
icu::UObject icu::UMemory

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,
  kFormatSymbolCount = kNineDigitSymbol + 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. More...
 
 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. More...
 
 DecimalFormatSymbols (UErrorCode &status)
 Create a DecimalFormatSymbols object for the default locale. More...
 
 DecimalFormatSymbols (const DecimalFormatSymbols &)
 Copy constructor. More...
 
DecimalFormatSymbolsoperator= (const DecimalFormatSymbols &)
 Assignment operator. More...
 
virtual ~DecimalFormatSymbols ()
 Destructor. More...
 
UBool operator== (const DecimalFormatSymbols &other) const
 Return true if another object is semantically equal to this one. More...
 
UBool operator!= (const DecimalFormatSymbols &other) const
 Return true if another object is semantically unequal to this one. More...
 
UnicodeString getSymbol (ENumberFormatSymbol symbol) const
 Get one of the format symbols by its enum constant. More...
 
void setSymbol (ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits)
 Set one of the format symbols by its enum constant. More...
 
Locale getLocale () const
 Returns the locale for which this object was constructed. More...
 
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Returns the locale for this object. More...
 
const UnicodeStringgetPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, UErrorCode &status) const
 Get pattern string for 'CurrencySpacing' that can be applied to currency format. More...
 
void setPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, const UnicodeString &pattern)
 Set pattern string for 'CurrencySpacing' that can be applied to currency format. More...
 
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class. More...
 
UBool isCustomCurrencySymbol () const
 
UBool isCustomIntlCurrencySymbol () const
 
UChar32 getCodePointZero () const
 
const UnicodeStringgetConstSymbol (ENumberFormatSymbol symbol) const
 Internal function - more efficient version of getSymbol, returning a const reference to one of the symbol strings. More...
 
const UnicodeStringgetConstDigitSymbol (int32_t digit) const
 Returns the const UnicodeString reference, like getConstSymbol, corresponding to the digit with the given value. More...
 
const char16_t * getCurrencyPattern (void) const
 Returns that pattern stored in currecy info. More...
 
- Public Member Functions inherited from icu::UObject
virtual ~UObject ()
 Destructor. More...
 

Static Public Member Functions

static DecimalFormatSymbolscreateWithLastResortData (UErrorCode &status)
 Creates a DecimalFormatSymbols object with last-resort data. More...
 
static UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class. More...
 

Detailed Description

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.

Symbol Meaning
0 a digit
# a digit, zero shows as absent
. placeholder for decimal separator
, placeholder for grouping separator.
; separates formats.
- default negative prefix.
% divide by 100 and show as percentage
X any other characters can be used in the prefix or suffix
' used to quote special characters in a prefix or suffix.

[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 84 of file dcfmtsym.h.

Member Enumeration Documentation

◆ ENumberFormatSymbol

Constants for specifying a number format symbol.

Stable:
ICU 2.0
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.

Stable:
ICU 3.0
kMonetaryGroupingSeparatorSymbol 

The monetary grouping separator.

Stable:
ICU 3.6
kOneDigitSymbol 

One.

Stable:
ICU 4.6
kTwoDigitSymbol 

Two.

Stable:
ICU 4.6
kThreeDigitSymbol 

Three.

Stable:
ICU 4.6
kFourDigitSymbol 

Four.

Stable:
ICU 4.6
kFiveDigitSymbol 

Five.

Stable:
ICU 4.6
kSixDigitSymbol 

Six.

Stable:
ICU 4.6
kSevenDigitSymbol 

Seven.

Stable:
ICU 4.6
kEightDigitSymbol 

Eight.

Stable:
ICU 4.6
kNineDigitSymbol 

Nine.

Stable:
ICU 4.6
kExponentMultiplicationSymbol 

Multiplication sign.

Stable:
ICU 54
kFormatSymbolCount 

count symbol constants

Definition at line 90 of file dcfmtsym.h.

Constructor & Destructor Documentation

◆ DecimalFormatSymbols() [1/4]

icu::DecimalFormatSymbols::DecimalFormatSymbols ( const Locale locale,
UErrorCode status 
)

Create a DecimalFormatSymbols object for the given locale.

Parameters
localeThe locale to get symbols for.
statusInput/output parameter, set to success or failure code upon return.
Stable:
ICU 2.0

◆ DecimalFormatSymbols() [2/4]

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.

Parameters
localeThe locale to get symbols for.
nsThe numbering system.
statusInput/output parameter, set to success or failure code upon return.
Stable:
ICU 60

◆ DecimalFormatSymbols() [3/4]

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.

Parameters
statusInput/output parameter, set to success or failure code upon return.
Stable:
ICU 2.0

◆ DecimalFormatSymbols() [4/4]

icu::DecimalFormatSymbols::DecimalFormatSymbols ( const DecimalFormatSymbols )

Copy constructor.

Stable:
ICU 2.0

◆ ~DecimalFormatSymbols()

virtual icu::DecimalFormatSymbols::~DecimalFormatSymbols ( )
virtual

Destructor.

Stable:
ICU 2.0

Member Function Documentation

◆ createWithLastResortData()

static DecimalFormatSymbols* icu::DecimalFormatSymbols::createWithLastResortData ( UErrorCode status)
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.

Parameters
statusInput/output parameter, set to success or failure code upon return.
Returns
last-resort symbols
Stable:
ICU 52

◆ getCodePointZero()

UChar32 icu::DecimalFormatSymbols::getCodePointZero ( ) const
inline
Internal:
Do not use.

This API is for internal use only. For ICU use only

Definition at line 397 of file dcfmtsym.h.

References ULOC_FULLNAME_CAPACITY, and UNUM_CURRENCY_SPACING_COUNT.

◆ getConstDigitSymbol()

const UnicodeString & icu::DecimalFormatSymbols::getConstDigitSymbol ( int32_t  digit) const
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: http://bugs.icu-project.org/trac/ticket/13580

Parameters
digitThe digit, an integer between 0 and 9 inclusive. If outside the range 0 to 9, the zero digit is returned.
Returns
the format symbol for the given digit.
Internal:
Do not use. This API is for internal use only. This API is currently for ICU use only.

Definition at line 522 of file dcfmtsym.h.

◆ getConstSymbol()

const UnicodeString & icu::DecimalFormatSymbols::getConstSymbol ( ENumberFormatSymbol  symbol) const
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: http://bugs.icu-project.org/trac/ticket/13580

Parameters
symbolConstant to indicate a number format symbol.
Returns
the format symbol by the param 'symbol'
Internal:
Do not use. This API is for internal use only.

Definition at line 511 of file dcfmtsym.h.

◆ getCurrencyPattern()

const char16_t * icu::DecimalFormatSymbols::getCurrencyPattern ( void  ) const
inline

Returns that pattern stored in currecy info.

Internal API for use by NumberFormat API.

Internal:
Do not use. This API is for internal use only.

Definition at line 576 of file dcfmtsym.h.

References U_NAMESPACE_END.

◆ getDynamicClassID()

virtual UClassID icu::DecimalFormatSymbols::getDynamicClassID ( ) const
virtual

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Reimplemented from icu::UObject.

◆ getLocale() [1/2]

Locale icu::DecimalFormatSymbols::getLocale ( void  ) const
inline

Returns the locale for which this object was constructed.

Stable:
ICU 2.6

Definition at line 570 of file dcfmtsym.h.

◆ getLocale() [2/2]

Locale icu::DecimalFormatSymbols::getLocale ( ULocDataLocaleType  type,
UErrorCode status 
) const

Returns the locale for this object.

Two flavors are available: valid and actual locale.

Stable:
ICU 2.8

◆ getPatternForCurrencySpacing()

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.

Parameters
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.
statusInput/output parameter, set to success or failure code upon return.
Returns
pattern string for currencyMatch, surroundingMatch or spaceInsert. Return empty string if there is no data for this locale and its parent locales.
Stable:
ICU 4.8

◆ getStaticClassID()

static UClassID icu::DecimalFormatSymbols::getStaticClassID ( )
static

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2

◆ getSymbol()

UnicodeString icu::DecimalFormatSymbols::getSymbol ( ENumberFormatSymbol  symbol) const
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.

Parameters
symbolConstant to indicate a number format symbol.
Returns
the format symbols by the param 'symbol'
Stable:
ICU 2.0

Definition at line 499 of file dcfmtsym.h.

◆ isCustomCurrencySymbol()

UBool icu::DecimalFormatSymbols::isCustomCurrencySymbol ( ) const
inline
Internal:
Do not use.

This API is for internal use only. For ICU use only

Definition at line 383 of file dcfmtsym.h.

◆ isCustomIntlCurrencySymbol()

UBool icu::DecimalFormatSymbols::isCustomIntlCurrencySymbol ( ) const
inline
Internal:
Do not use.

This API is for internal use only. For ICU use only

Definition at line 390 of file dcfmtsym.h.

◆ operator!=()

UBool icu::DecimalFormatSymbols::operator!= ( const DecimalFormatSymbols other) const
inline

Return true if another object is semantically unequal to this one.

Parameters
otherthe object to be compared with.
Returns
true if another object is semantically unequal to this one.
Stable:
ICU 2.0

Definition at line 265 of file dcfmtsym.h.

References FALSE, icu::UObject::getDynamicClassID(), and icu::operator==().

◆ operator=()

DecimalFormatSymbols& icu::DecimalFormatSymbols::operator= ( const DecimalFormatSymbols )

Assignment operator.

Stable:
ICU 2.0

◆ operator==()

UBool icu::DecimalFormatSymbols::operator== ( const DecimalFormatSymbols other) const

Return true if another object is semantically equal to this one.

Parameters
otherthe object to be compared with.
Returns
true if another object is semantically equal to this one.
Stable:
ICU 2.0

◆ setPatternForCurrencySpacing()

void icu::DecimalFormatSymbols::setPatternForCurrencySpacing ( UCurrencySpacing  type,
UBool  beforeCurrency,
const UnicodeString pattern 
)

Set pattern string for 'CurrencySpacing' that can be applied to currency format.

Parameters
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.
Stable:
ICU 4.8

◆ setSymbol()

void icu::DecimalFormatSymbols::setSymbol ( ENumberFormatSymbol  symbol,
const UnicodeString value,
const UBool  propogateDigits = TRUE 
)
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.

Parameters
symbolConstant to indicate a number format symbol.
valuevalue of the format symbol
propogateDigitsIf 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.
Stable:
ICU 2.0

Definition at line 537 of file dcfmtsym.h.

References icu::UnicodeString::char32At(), icu::UnicodeString::countChar32(), TRUE, and u_charDigitValue().


The documentation for this class was generated from the following file: