w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

unum.h File Reference

C API: Compatibility APIs for number formatting. More...

Include dependency graph for unum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef voidUNumberFormat
 
typedef enum UNumberFormatStyle UNumberFormatStyle
 
typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode
 
typedef enum UNumberFormatPadPosition UNumberFormatPadPosition
 
typedef enum UNumberCompactStyle UNumberCompactStyle
 
typedef enum UCurrencySpacing UCurrencySpacing
 
typedef enum UNumberFormatFields UNumberFormatFields
 
typedef enum UNumberFormatMinimumGroupingDigits UNumberFormatMinimumGroupingDigits
 
typedef enum UNumberFormatAttributeValue UNumberFormatAttributeValue
 
typedef enum UNumberFormatAttribute UNumberFormatAttribute
 
typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute
 
typedef enum UNumberFormatSymbol UNumberFormatSymbol
 

Enumerations

enum  UNumberFormatStyle {
  UNUM_PATTERN_DECIMAL =0 , UNUM_DECIMAL =1 , UNUM_CURRENCY =2 , UNUM_PERCENT =3 ,
  UNUM_SCIENTIFIC =4 , UNUM_SPELLOUT =5 , UNUM_ORDINAL =6 , UNUM_DURATION =7 ,
  UNUM_NUMBERING_SYSTEM =8 , UNUM_PATTERN_RULEBASED =9 , UNUM_CURRENCY_ISO =10 , UNUM_CURRENCY_PLURAL =11 ,
  UNUM_CURRENCY_ACCOUNTING =12 , UNUM_CASH_CURRENCY =13 , UNUM_DECIMAL_COMPACT_SHORT =14 , UNUM_DECIMAL_COMPACT_LONG =15 ,
  UNUM_CURRENCY_STANDARD =16 , UNUM_FORMAT_STYLE_COUNT =17 , UNUM_DEFAULT = UNUM_DECIMAL , UNUM_IGNORE = UNUM_PATTERN_DECIMAL
}
 
enum  UNumberFormatRoundingMode {
  UNUM_ROUND_CEILING , UNUM_ROUND_FLOOR , UNUM_ROUND_DOWN , UNUM_ROUND_UP ,
  UNUM_ROUND_HALFEVEN , UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN , UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1 , UNUM_ROUND_HALFUP ,
  UNUM_ROUND_UNNECESSARY
}
 
enum  UNumberFormatPadPosition { UNUM_PAD_BEFORE_PREFIX , UNUM_PAD_AFTER_PREFIX , UNUM_PAD_BEFORE_SUFFIX , UNUM_PAD_AFTER_SUFFIX }
 
enum  UNumberCompactStyle { UNUM_SHORT , UNUM_LONG }
 
enum  UCurrencySpacing { UNUM_CURRENCY_MATCH , UNUM_CURRENCY_SURROUNDING_MATCH , UNUM_CURRENCY_INSERT , UNUM_CURRENCY_SPACING_COUNT }
 
enum  UNumberFormatFields {
  UNUM_INTEGER_FIELD , UNUM_FRACTION_FIELD , UNUM_DECIMAL_SEPARATOR_FIELD , UNUM_EXPONENT_SYMBOL_FIELD ,
  UNUM_EXPONENT_SIGN_FIELD , UNUM_EXPONENT_FIELD , UNUM_GROUPING_SEPARATOR_FIELD , UNUM_CURRENCY_FIELD ,
  UNUM_PERCENT_FIELD , UNUM_PERMILL_FIELD , UNUM_SIGN_FIELD , UNUM_MEASURE_UNIT_FIELD ,
  UNUM_COMPACT_FIELD , UNUM_FIELD_COUNT = UNUM_SIGN_FIELD + 3
}
 
enum  UNumberFormatMinimumGroupingDigits { UNUM_MINIMUM_GROUPING_DIGITS_AUTO = -2 , UNUM_MINIMUM_GROUPING_DIGITS_MIN2 = -3 }
 
enum  UNumberFormatAttributeValue { UNUM_NO = 0 , UNUM_YES = 1 , UNUM_MAYBE = 2 }
 
enum  UNumberFormatAttribute {
  UNUM_PARSE_INT_ONLY , UNUM_GROUPING_USED , UNUM_DECIMAL_ALWAYS_SHOWN , UNUM_MAX_INTEGER_DIGITS ,
  UNUM_MIN_INTEGER_DIGITS , UNUM_INTEGER_DIGITS , UNUM_MAX_FRACTION_DIGITS , UNUM_MIN_FRACTION_DIGITS ,
  UNUM_FRACTION_DIGITS , UNUM_MULTIPLIER , UNUM_GROUPING_SIZE , UNUM_ROUNDING_MODE ,
  UNUM_ROUNDING_INCREMENT , UNUM_FORMAT_WIDTH , UNUM_PADDING_POSITION , UNUM_SECONDARY_GROUPING_SIZE ,
  UNUM_SIGNIFICANT_DIGITS_USED , UNUM_MIN_SIGNIFICANT_DIGITS , UNUM_MAX_SIGNIFICANT_DIGITS , UNUM_LENIENT_PARSE ,
  UNUM_PARSE_ALL_INPUT = 20 , UNUM_SCALE = 21 , UNUM_MINIMUM_GROUPING_DIGITS = 22 , UNUM_CURRENCY_USAGE = 23 ,
  UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF , UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000 , UNUM_PARSE_NO_EXPONENT = 0x1001 , UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002 ,
  UNUM_PARSE_CASE_SENSITIVE = 0x1003 , UNUM_SIGN_ALWAYS_SHOWN = 0x1004 , UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005
}
 
enum  UNumberFormatTextAttribute {
  UNUM_POSITIVE_PREFIX , UNUM_POSITIVE_SUFFIX , UNUM_NEGATIVE_PREFIX , UNUM_NEGATIVE_SUFFIX ,
  UNUM_PADDING_CHARACTER , UNUM_CURRENCY_CODE , UNUM_DEFAULT_RULESET , UNUM_PUBLIC_RULESETS
}
 
enum  UNumberFormatSymbol {
  UNUM_DECIMAL_SEPARATOR_SYMBOL = 0 , UNUM_GROUPING_SEPARATOR_SYMBOL = 1 , UNUM_PATTERN_SEPARATOR_SYMBOL = 2 , UNUM_PERCENT_SYMBOL = 3 ,
  UNUM_ZERO_DIGIT_SYMBOL = 4 , UNUM_DIGIT_SYMBOL = 5 , UNUM_MINUS_SIGN_SYMBOL = 6 , UNUM_PLUS_SIGN_SYMBOL = 7 ,
  UNUM_CURRENCY_SYMBOL = 8 , UNUM_INTL_CURRENCY_SYMBOL = 9 , UNUM_MONETARY_SEPARATOR_SYMBOL = 10 , UNUM_EXPONENTIAL_SYMBOL = 11 ,
  UNUM_PERMILL_SYMBOL = 12 , UNUM_PAD_ESCAPE_SYMBOL = 13 , UNUM_INFINITY_SYMBOL = 14 , UNUM_NAN_SYMBOL = 15 ,
  UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16 , UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17 , UNUM_ONE_DIGIT_SYMBOL = 18 , UNUM_TWO_DIGIT_SYMBOL = 19 ,
  UNUM_THREE_DIGIT_SYMBOL = 20 , UNUM_FOUR_DIGIT_SYMBOL = 21 , UNUM_FIVE_DIGIT_SYMBOL = 22 , UNUM_SIX_DIGIT_SYMBOL = 23 ,
  UNUM_SEVEN_DIGIT_SYMBOL = 24 , UNUM_EIGHT_DIGIT_SYMBOL = 25 , UNUM_NINE_DIGIT_SYMBOL = 26 , UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27 ,
  UNUM_FORMAT_SYMBOL_COUNT = 28
}
 

Functions

UNumberFormatunum_open_68 (UNumberFormatStyle style, const UChar *pattern, int32_t patternLength, const char *locale, UParseError *parseErr, UErrorCode *status)
 
void unum_close_68 (UNumberFormat *fmt)
 
UNumberFormatunum_clone_68 (const UNumberFormat *fmt, UErrorCode *status)
 
int32_t unum_format_68 (const UNumberFormat *fmt, int32_t number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_formatInt64_68 (const UNumberFormat *fmt, int64_t number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_formatDouble_68 (const UNumberFormat *fmt, double number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_formatDoubleForFields_68 (const UNumberFormat *format, double number, UChar *result, int32_t resultLength, UFieldPositionIterator *fpositer, UErrorCode *status)
 
int32_t unum_formatDecimal_68 (const UNumberFormat *fmt, const char *number, int32_t length, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_formatDoubleCurrency_68 (const UNumberFormat *fmt, double number, UChar *currency, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_formatUFormattable_68 (const UNumberFormat *fmt, const UFormattable *number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
 
int32_t unum_parse_68 (const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
 
int64_t unum_parseInt64_68 (const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
 
double unum_parseDouble_68 (const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
 
int32_t unum_parseDecimal_68 (const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, char *outBuf, int32_t outBufLength, UErrorCode *status)
 
double unum_parseDoubleCurrency_68 (const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UChar *currency, UErrorCode *status)
 
UFormattableunum_parseToUFormattable_68 (const UNumberFormat *fmt, UFormattable *result, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
 
void unum_applyPattern_68 (UNumberFormat *format, UBool localized, const UChar *pattern, int32_t patternLength, UParseError *parseError, UErrorCode *status)
 
const char * unum_getAvailable_68 (int32_t localeIndex)
 
int32_t unum_countAvailable_68 (void)
 
int32_t unum_getAttribute_68 (const UNumberFormat *fmt, UNumberFormatAttribute attr)
 
void unum_setAttribute_68 (UNumberFormat *fmt, UNumberFormatAttribute attr, int32_t newValue)
 
double unum_getDoubleAttribute_68 (const UNumberFormat *fmt, UNumberFormatAttribute attr)
 
void unum_setDoubleAttribute_68 (UNumberFormat *fmt, UNumberFormatAttribute attr, double newValue)
 
int32_t unum_getTextAttribute_68 (const UNumberFormat *fmt, UNumberFormatTextAttribute tag, UChar *result, int32_t resultLength, UErrorCode *status)
 
void unum_setTextAttribute_68 (UNumberFormat *fmt, UNumberFormatTextAttribute tag, const UChar *newValue, int32_t newValueLength, UErrorCode *status)
 
int32_t unum_toPattern_68 (const UNumberFormat *fmt, UBool isPatternLocalized, UChar *result, int32_t resultLength, UErrorCode *status)
 
int32_t unum_getSymbol_68 (const UNumberFormat *fmt, UNumberFormatSymbol symbol, UChar *buffer, int32_t size, UErrorCode *status)
 
void unum_setSymbol_68 (UNumberFormat *fmt, UNumberFormatSymbol symbol, const UChar *value, int32_t length, UErrorCode *status)
 
const char * unum_getLocaleByType_68 (const UNumberFormat *fmt, ULocDataLocaleType type, UErrorCode *status)
 
void unum_setContext_68 (UNumberFormat *fmt, UDisplayContext value, UErrorCode *status)
 
UDisplayContext unum_getContext_68 (const UNumberFormat *fmt, UDisplayContextType type, UErrorCode *status)
 

Detailed Description

C API: Compatibility APIs for number formatting.

Number Format C API

IMPORTANT: New users with are strongly encouraged to see if unumberformatter.h fits their use case. Although not deprecated, this header is provided for backwards compatibility only.

Number Format C API Provides functions for formatting and parsing a number. Also provides methods for determining which locales have number formats, and what their names are.

UNumberFormat helps you to format and parse numbers for any locale. Your code can be completely independent of the locale conventions for decimal points, thousands-separators, or even the particular decimal digits used, or whether the number format is even decimal. There are different number format styles like decimal, currency, percent and spellout.

To format a number for the current Locale, use one of the static factory methods:

UChar myString[20];
double myNumber = 7.0;
unum_formatDouble(nf, myNumber, myString, 20, NULL, &status);
printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
int printf()
unsigned char UChar
Definition: bzip2.c:163
#define NULL
Definition: ftobjs.h:61
#define status
@ UNUM_DEFAULT
Definition: unum.h:266
void * UNumberFormat
Definition: unum.h:144
#define unum_formatDouble
Definition: urename.h:1217
#define unum_open
Definition: urename.h:1229
UErrorCode
Definition: utypes.h:431
@ U_ZERO_ERROR
Definition: utypes.h:465

If you are formatting multiple numbers, it is more efficient to get the format and use it multiple times so that the system doesn't have to fetch the information about the local language and country conventions multiple times.

uint32_t i, resultlength, reslenneeded;
uint32_t a[] = { 123, 3333, -1234567 };
const uint32_t a_len = sizeof(a) / sizeof(a[0]);
for (i = 0; i < a_len; i++) {
resultlength=0;
reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);
resultlength=reslenneeded+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
unum_format(nf, a[i], result, resultlength, &pos, &status);
}
printf( " Example 2: %s\n", austrdup(result));
}
#define free(a)
Definition: decNumber.cpp:310
#define a(n)
Definition: gpos-common.c:148
small capitals from c petite p scientific i
Definition: afcover.h:80
unsigned int uint32_t
Definition: stdint.h:80
#define malloc
Definition: alloca.c:91
const int * pos
Definition: combiners.h:905
#define unum_format
Definition: urename.h:1215
@ U_BUFFER_OVERFLOW_ERROR
Definition: utypes.h:481

To format a number for a different Locale, specify it in the call to unum_open().

UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, "fr_FR", NULL, &success)

You can use a NumberFormat API unum_parse() to parse.

signed int int32_t
Definition: stdint.h:77
int num
Definition: disdvi.c:621
#define str(s)
Definition: sh6.c:399
#define unum_parse
Definition: urename.h:1230
#define u_strlen
Definition: urename.h:384

Use UNUM_DECIMAL to get the normal number format for that country. There are other static options available. Use UNUM_CURRENCY to get the currency number format for that country. Use UNUM_PERCENT to get a format for displaying percentages. With this format, a fraction from 0.53 is displayed as 53%.

Use a pattern to create either a DecimalFormat or a RuleBasedNumberFormat formatter. The pattern must conform to the syntax defined for those formatters.

You can also control the display of numbers with such function as unum_getAttributes() and unum_setAttributes(), which let you set the minimum fraction digits, grouping, etc.

See also
UNumberFormatAttributes for more details

You can also use forms of the parse and format methods with ParsePosition and UFieldPosition to allow you to:

  • (a) progressively parse through pieces of a string.
  • (b) align the decimal point and other areas.

It is also possible to change or set the symbols used for a particular locale like the currency symbol, the grouping separator , monetary separator etc by making use of functions unum_setSymbols() and unum_getSymbols().

Definition in file unum.h.

Typedef Documentation

◆ UCurrencySpacing

@stable ICU 4.8

Definition at line 144 of file unum.h.

◆ UNumberCompactStyle

Constants for specifying short or long format. @stable ICU 51

◆ UNumberFormat

typedef void* UNumberFormat

A number formatter. For usage in C programs. @stable ICU 2.0

Definition at line 144 of file unum.h.

◆ UNumberFormatAttribute

The possible UNumberFormat numeric attributes @stable ICU 2.0

◆ UNumberFormatAttributeValue

◆ UNumberFormatFields

FieldPosition and UFieldPosition selectors for format fields defined by NumberFormat and UNumberFormat. @stable ICU 49

◆ UNumberFormatMinimumGroupingDigits

Selectors with special numeric values to use locale default minimum grouping digits for the DecimalFormat/UNumberFormat setMinimumGroupingDigits method. Do not use these constants with the [U]NumberFormatter API.

@draft ICU 68

◆ UNumberFormatPadPosition

The possible number format pad positions. @stable ICU 2.0

◆ UNumberFormatRoundingMode

The possible number format rounding modes.

For more detail on rounding modes, see: https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes

@stable ICU 2.0

◆ UNumberFormatStyle

The possible number format styles. @stable ICU 2.0

◆ UNumberFormatSymbol

Constants for specifying a number format symbol. @stable ICU 2.0

◆ UNumberFormatTextAttribute

The possible UNumberFormat text attributes @stable ICU 2.0

Enumeration Type Documentation

◆ UCurrencySpacing

Constants for specifying currency spacing @stable ICU 4.8

Enumerator
UNUM_CURRENCY_MATCH 

@stable ICU 4.8

UNUM_CURRENCY_SURROUNDING_MATCH 

@stable ICU 4.8

UNUM_CURRENCY_INSERT 

@stable ICU 4.8

UNUM_CURRENCY_SPACING_COUNT 

One more than the highest normal UCurrencySpacing value.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.

Definition at line 334 of file unum.h.

◆ UNumberCompactStyle

Constants for specifying short or long format. @stable ICU 51

Enumerator
UNUM_SHORT 

@stable ICU 51

UNUM_LONG 

@stable ICU 51 @stable ICU 51

Definition at line 322 of file unum.h.

◆ UNumberFormatAttribute

The possible UNumberFormat numeric attributes @stable ICU 2.0

Enumerator
UNUM_PARSE_INT_ONLY 

Parse integers only

UNUM_GROUPING_USED 

Use grouping separator

UNUM_DECIMAL_ALWAYS_SHOWN 

Always show decimal point

UNUM_MAX_INTEGER_DIGITS 

Maximum integer digits

UNUM_MIN_INTEGER_DIGITS 

Minimum integer digits

UNUM_INTEGER_DIGITS 

Integer digits

UNUM_MAX_FRACTION_DIGITS 

Maximum fraction digits

UNUM_MIN_FRACTION_DIGITS 

Minimum fraction digits

UNUM_FRACTION_DIGITS 

Fraction digits

UNUM_MULTIPLIER 

Multiplier

UNUM_GROUPING_SIZE 

Grouping size

UNUM_ROUNDING_MODE 

Rounding Mode

UNUM_ROUNDING_INCREMENT 

Rounding increment

UNUM_FORMAT_WIDTH 

The width to which the output of format() is padded.

UNUM_PADDING_POSITION 

The position at which padding will take place.

UNUM_SECONDARY_GROUPING_SIZE 

Secondary grouping size

UNUM_SIGNIFICANT_DIGITS_USED 

Use significant digits @stable ICU 3.0

UNUM_MIN_SIGNIFICANT_DIGITS 

Minimum significant digits @stable ICU 3.0

UNUM_MAX_SIGNIFICANT_DIGITS 

Maximum significant digits @stable ICU 3.0

UNUM_LENIENT_PARSE 

Lenient parse mode used by rule-based formats. @stable ICU 3.0

UNUM_PARSE_ALL_INPUT 

Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath), UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic). This is an internal ICU API. Do not use.

UNUM_SCALE 

Scale, which adjusts the position of the decimal point when formatting. Amounts will be multiplied by 10 ^ (scale) before they are formatted. The default value for the scale is 0 ( no adjustment ).

Example: setting the scale to 3, 123 formats as "123,000"

Example: setting the scale to -4, 123 formats as "0.0123"

This setting is analogous to getMultiplierScale() and setMultiplierScale() in decimfmt.h.

@stable ICU 51

UNUM_MINIMUM_GROUPING_DIGITS 

Minimum grouping digits; most commonly set to 2 to print "1000" instead of "1,000". See DecimalFormat::getMinimumGroupingDigits().

For better control over grouping strategies, use UNumberFormatter.

@stable ICU 64

UNUM_CURRENCY_USAGE 

if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose, otherwise it is UNUM_CURRENCY_CASH purpose Default: 0 (UNUM_CURRENCY_STANDARD purpose) @stable ICU 54

UNUM_MAX_NONBOOLEAN_ATTRIBUTE 

One below the first bitfield-boolean item. All items after this one are stored in boolean form.

UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS 

If 1, specifies that if setting the "max integer digits" attribute would truncate a value, set an error status rather than silently truncating. For example, formatting the value 1234 with 4 max int digits would succeed, but formatting 12345 would fail. There is no effect on parsing. Default: 0 (not set) @stable ICU 50

UNUM_PARSE_NO_EXPONENT 

if this attribute is set to 1, specifies that, if the pattern doesn't contain an exponent, the exponent will not be parsed. If the pattern does contain an exponent, this attribute has no effect. Has no effect on formatting. Default: 0 (unset) @stable ICU 50

UNUM_PARSE_DECIMAL_MARK_REQUIRED 

if this attribute is set to 1, specifies that, if the pattern contains a decimal mark the input is required to have one. If this attribute is set to 0, specifies that input does not have to contain a decimal mark. Has no effect on formatting. Default: 0 (unset) @stable ICU 54

UNUM_PARSE_CASE_SENSITIVE 

Parsing: if set to 1, parsing is sensitive to case (lowercase/uppercase).

@stable ICU 64

UNUM_SIGN_ALWAYS_SHOWN 

Formatting: if set to 1, whether to show the plus sign on non-negative numbers.

For better control over sign display, use UNumberFormatter.

@stable ICU 64

UNUM_LIMIT_BOOLEAN_ATTRIBUTE 

Limit of boolean attributes. (value should not depend on U_HIDE conditionals)

Definition at line 994 of file unum.h.

◆ UNumberFormatAttributeValue

Enumerator
UNUM_NO 
UNUM_YES 
UNUM_MAYBE 

Definition at line 978 of file unum.h.

◆ UNumberFormatFields

FieldPosition and UFieldPosition selectors for format fields defined by NumberFormat and UNumberFormat. @stable ICU 49

Enumerator
UNUM_INTEGER_FIELD 

@stable ICU 49

UNUM_FRACTION_FIELD 

@stable ICU 49

UNUM_DECIMAL_SEPARATOR_FIELD 

@stable ICU 49

UNUM_EXPONENT_SYMBOL_FIELD 

@stable ICU 49

UNUM_EXPONENT_SIGN_FIELD 

@stable ICU 49

UNUM_EXPONENT_FIELD 

@stable ICU 49

UNUM_GROUPING_SEPARATOR_FIELD 

@stable ICU 49

UNUM_CURRENCY_FIELD 

@stable ICU 49

UNUM_PERCENT_FIELD 

@stable ICU 49

UNUM_PERMILL_FIELD 

@stable ICU 49

UNUM_SIGN_FIELD 

@stable ICU 49

UNUM_MEASURE_UNIT_FIELD 

@stable ICU 64

UNUM_COMPACT_FIELD 

@stable ICU 64

UNUM_FIELD_COUNT 

One more than the highest normal UNumberFormatFields value.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.

Definition at line 360 of file unum.h.

◆ UNumberFormatMinimumGroupingDigits

Selectors with special numeric values to use locale default minimum grouping digits for the DecimalFormat/UNumberFormat setMinimumGroupingDigits method. Do not use these constants with the [U]NumberFormatter API.

@draft ICU 68

Enumerator
UNUM_MINIMUM_GROUPING_DIGITS_AUTO 

Display grouping using the default strategy for all locales. @draft ICU 68

UNUM_MINIMUM_GROUPING_DIGITS_MIN2 

Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (such that there is a minimum of two digits before the first separator). @draft ICU 68

Definition at line 406 of file unum.h.

◆ UNumberFormatPadPosition

The possible number format pad positions. @stable ICU 2.0

Enumerator
UNUM_PAD_BEFORE_PREFIX 
UNUM_PAD_AFTER_PREFIX 
UNUM_PAD_BEFORE_SUFFIX 
UNUM_PAD_AFTER_SUFFIX 

Definition at line 311 of file unum.h.

◆ UNumberFormatRoundingMode

The possible number format rounding modes.

For more detail on rounding modes, see: https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes

@stable ICU 2.0

Enumerator
UNUM_ROUND_CEILING 
UNUM_ROUND_FLOOR 
UNUM_ROUND_DOWN 
UNUM_ROUND_UP 
UNUM_ROUND_HALFEVEN 

Half-even rounding @stable, ICU 3.8

UNUM_FOUND_HALFEVEN 

Half-even rounding, misspelled name

Deprecated:
, ICU 3.8
UNUM_ROUND_HALFDOWN 
UNUM_ROUND_HALFUP 
UNUM_ROUND_UNNECESSARY 

ROUND_UNNECESSARY reports an error if formatted result is not exact. @stable ICU 4.8

Definition at line 282 of file unum.h.

◆ UNumberFormatStyle

The possible number format styles. @stable ICU 2.0

Enumerator
UNUM_PATTERN_DECIMAL 

Decimal format defined by a pattern string. @stable ICU 3.0

UNUM_DECIMAL 

Decimal format ("normal" style). @stable ICU 2.0

UNUM_CURRENCY 

Currency format (generic). Defaults to UNUM_CURRENCY_STANDARD style (using currency symbol, e.g., "$1.00", with non-accounting style for negative values e.g. using minus sign). The specific style may be specified using the -cf- locale key. @stable ICU 2.0

UNUM_PERCENT 

Percent format @stable ICU 2.0

UNUM_SCIENTIFIC 

Scientific format @stable ICU 2.1

UNUM_SPELLOUT 

Spellout rule-based format. The default ruleset can be specified/changed using unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. @stable ICU 2.0

UNUM_ORDINAL 

Ordinal rule-based format . The default ruleset can be specified/changed using unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. @stable ICU 3.0

UNUM_DURATION 

Duration rule-based format @stable ICU 3.0

UNUM_NUMBERING_SYSTEM 

Numbering system rule-based format @stable ICU 4.2

UNUM_PATTERN_RULEBASED 

Rule-based format defined by a pattern string. @stable ICU 3.0

UNUM_CURRENCY_ISO 

Currency format with an ISO currency code, e.g., "USD1.00". @stable ICU 4.8

UNUM_CURRENCY_PLURAL 

Currency format with a pluralized currency name, e.g., "1.00 US dollar" and "3.00 US dollars". @stable ICU 4.8

UNUM_CURRENCY_ACCOUNTING 

Currency format for accounting, e.g., "($3.00)" for negative currency amount instead of "-$3.00" (UNUM_CURRENCY). Overrides any style specified using -cf- key in locale. @stable ICU 53

UNUM_CASH_CURRENCY 

Currency format with a currency symbol given CASH usage, e.g., "NT$3" instead of "NT$3.23". @stable ICU 54

UNUM_DECIMAL_COMPACT_SHORT 

Decimal format expressed using compact notation (short form, corresponds to UNumberCompactStyle=UNUM_SHORT) e.g. "23K", "45B" @stable ICU 56

UNUM_DECIMAL_COMPACT_LONG 

Decimal format expressed using compact notation (long form, corresponds to UNumberCompactStyle=UNUM_LONG) e.g. "23 thousand", "45 billion" @stable ICU 56

UNUM_CURRENCY_STANDARD 

Currency format with a currency symbol, e.g., "$1.00", using non-accounting style for negative values (e.g. minus sign). Overrides any style specified using -cf- key in locale. @stable ICU 56

UNUM_FORMAT_STYLE_COUNT 

One more than the highest normal UNumberFormatStyle value.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.
UNUM_DEFAULT 

Default format @stable ICU 2.0

UNUM_IGNORE 

Alias for UNUM_PATTERN_DECIMAL @stable ICU 3.0

Definition at line 149 of file unum.h.

◆ UNumberFormatSymbol

Constants for specifying a number format symbol. @stable ICU 2.0

Enumerator
UNUM_DECIMAL_SEPARATOR_SYMBOL 

The decimal separator

UNUM_GROUPING_SEPARATOR_SYMBOL 

The grouping separator

UNUM_PATTERN_SEPARATOR_SYMBOL 

The pattern separator

UNUM_PERCENT_SYMBOL 

The percent sign

UNUM_ZERO_DIGIT_SYMBOL 

Zero

UNUM_DIGIT_SYMBOL 

Character representing a digit in the pattern

UNUM_MINUS_SIGN_SYMBOL 

The minus sign

UNUM_PLUS_SIGN_SYMBOL 

The plus sign

UNUM_CURRENCY_SYMBOL 

The currency symbol

UNUM_INTL_CURRENCY_SYMBOL 

The international currency symbol

UNUM_MONETARY_SEPARATOR_SYMBOL 

The monetary separator

UNUM_EXPONENTIAL_SYMBOL 

The exponential symbol

UNUM_PERMILL_SYMBOL 

Per mill symbol

UNUM_PAD_ESCAPE_SYMBOL 

Escape padding character

UNUM_INFINITY_SYMBOL 

Infinity symbol

UNUM_NAN_SYMBOL 

Nan symbol

UNUM_SIGNIFICANT_DIGIT_SYMBOL 

Significant digit symbol @stable ICU 3.0

UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL 

The monetary grouping separator @stable ICU 3.6

UNUM_ONE_DIGIT_SYMBOL 

One @stable ICU 4.6

UNUM_TWO_DIGIT_SYMBOL 

Two @stable ICU 4.6

UNUM_THREE_DIGIT_SYMBOL 

Three @stable ICU 4.6

UNUM_FOUR_DIGIT_SYMBOL 

Four @stable ICU 4.6

UNUM_FIVE_DIGIT_SYMBOL 

Five @stable ICU 4.6

UNUM_SIX_DIGIT_SYMBOL 

Six @stable ICU 4.6

UNUM_SEVEN_DIGIT_SYMBOL 

Seven @stable ICU 4.6

UNUM_EIGHT_DIGIT_SYMBOL 

Eight @stable ICU 4.6

UNUM_NINE_DIGIT_SYMBOL 

Nine @stable ICU 4.6

UNUM_EXPONENT_MULTIPLICATION_SYMBOL 

Multiplication sign @stable ICU 54

UNUM_FORMAT_SYMBOL_COUNT 

One more than the highest normal UNumberFormatSymbol value.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.

Definition at line 1327 of file unum.h.

◆ UNumberFormatTextAttribute

The possible UNumberFormat text attributes @stable ICU 2.0

Enumerator
UNUM_POSITIVE_PREFIX 

Positive prefix

UNUM_POSITIVE_SUFFIX 

Positive suffix

UNUM_NEGATIVE_PREFIX 

Negative prefix

UNUM_NEGATIVE_SUFFIX 

Negative suffix

UNUM_PADDING_CHARACTER 

The character used to pad to the format width.

UNUM_CURRENCY_CODE 

The ISO currency code

UNUM_DEFAULT_RULESET 

The default rule set, such as "%spellout-numbering-year:", "%spellout-cardinal:", "%spellout-ordinal-masculine-plural:", "%spellout-ordinal-feminine:", or "%spellout-ordinal-neuter:". The available public rulesets can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. This is only available with rule-based formatters. @stable ICU 3.0

UNUM_PUBLIC_RULESETS 

The public rule sets. This is only available with rule-based formatters. This is a read-only attribute. The public rulesets are returned as a single string, with each ruleset name delimited by ';' (semicolon). See the CLDR LDML spec for more information about RBNF rulesets: http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting @stable ICU 3.0

Definition at line 1218 of file unum.h.

Function Documentation

◆ unum_applyPattern_68()

void unum_applyPattern_68 ( UNumberFormat format,
UBool  localized,
const UChar pattern,
int32_t  patternLength,
UParseError parseError,
UErrorCode status 
)

Set the pattern used by a UNumberFormat. This can only be used on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR in the status.

Parameters
formatThe formatter to set.
localizedtrue if the pattern is localized, false otherwise.
patternThe new pattern
patternLengthThe length of pattern, or -1 if null-terminated.
parseErrorA pointer to UParseError to receive information about errors occurred during parsing, or NULL if no parse error information is desired.
statusA pointer to an input-output UErrorCode.
See also
unum_toPattern
DecimalFormat @stable ICU 2.0

Definition at line 832 of file unum.cpp.

References fmt, len, NULL, pat, patternLength, status, u_strlen, U_UNSUPPORTED_ERROR, and U_ZERO_ERROR.

◆ unum_clone_68()

UNumberFormat* unum_clone_68 ( const UNumberFormat fmt,
UErrorCode status 
)

Open a copy of a UNumberFormat. This function performs a deep copy.

Parameters
fmtThe format to copy
statusA pointer to an UErrorCode to receive any errors.
Returns
A pointer to a UNumberFormat identical to fmt. @stable ICU 2.0

Definition at line 153 of file unum.cpp.

References fmt, NULL, res, status, U_ASSERT, U_FAILURE, and U_MEMORY_ALLOCATION_ERROR.

◆ unum_close_68()

void unum_close_68 ( UNumberFormat fmt)

Close a UNumberFormat. Once closed, a UNumberFormat may no longer be used.

Parameters
fmtThe formatter to close. @stable ICU 2.0

Definition at line 147 of file unum.cpp.

References fmt.

◆ unum_countAvailable_68()

int32_t unum_countAvailable_68 ( void  )

Determine how many locales have decimal formatting patterns available. The results of this call are not valid for rule-based number formats. This function is useful for determining the loop ending condition for calls to unum_getAvailable.

Returns
The number of locales for which decimal formatting patterns are available.
See also
unum_getAvailable @stable ICU 2.0

Definition at line 506 of file unum.cpp.

References uloc_countAvailable.

◆ unum_format_68()

int32_t unum_format_68 ( const UNumberFormat fmt,
int32_t  number,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format an integer using a UNumberFormat. The integer will be formatted according to the UNumberFormat's locale.

Parameters
fmtThe formatter to use.
numberThe number to format.
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengthThe maximum size of result.
posA pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case no field
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_formatInt64
unum_formatDouble
unum_parse
unum_parseInt64
unum_parseDouble
UFieldPosition @stable ICU 2.0

Definition at line 179 of file unum.cpp.

References fmt, pos, check-static-inits::result, status, and unum_formatInt64.

◆ unum_formatDecimal_68()

int32_t unum_formatDecimal_68 ( const UNumberFormat fmt,
const char *  number,
int32_t  length,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format a decimal number using a UNumberFormat. The number will be formatted according to the UNumberFormat's locale. The syntax of the input number is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal

Parameters
fmtThe formatter to use.
numberThe number to format.
lengthThe length of the input number, or -1 if the input is nul-terminated.
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengthThe maximum size of result.
posA pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case it is ignored.
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_format
unum_formatInt64
unum_parse
unum_parseInt64
unum_parseDouble
UFieldPosition @stable ICU 4.4

Definition at line 284 of file unum.cpp.

References fmt, fp, length, NULL, pos, check-static-inits::result, status, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, and uprv_strlen.

◆ unum_formatDouble_68()

int32_t unum_formatDouble_68 ( const UNumberFormat fmt,
double  number,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format a double using a UNumberFormat. The double will be formatted according to the UNumberFormat's locale.

Parameters
fmtThe formatter to use.
numberThe number to format.
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengthThe maximum size of result.
posA pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case no field
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_format
unum_formatInt64
unum_parse
unum_parseInt64
unum_parseDouble
UFieldPosition @stable ICU 2.0

Definition at line 223 of file unum.cpp.

References fmt, fp, NULL, pos, res, check-static-inits::result, status, and U_FAILURE.

◆ unum_formatDoubleCurrency_68()

int32_t unum_formatDoubleCurrency_68 ( const UNumberFormat fmt,
double  number,
UChar currency,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format a double currency amount using a UNumberFormat. The double will be formatted according to the UNumberFormat's locale.

Parameters
fmtthe formatter to use
numberthe number to format
currencythe 3-letter null-terminated ISO 4217 currency code
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengththe maximum number of UChars to write to result
posa pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case it is ignored.
statusa pointer to an input-output UErrorCode
Returns
the total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_formatDouble
unum_parseDoubleCurrency
UFieldPosition @stable ICU 3.0

Definition at line 328 of file unum.cpp.

References fmt, fp, n, NULL, pos, res, check-static-inits::result, status, U_FAILURE, and U_MEMORY_ALLOCATION_ERROR.

◆ unum_formatDoubleForFields_68()

int32_t unum_formatDoubleForFields_68 ( const UNumberFormat format,
double  number,
UChar result,
int32_t  resultLength,
UFieldPositionIterator fpositer,
UErrorCode status 
)

Format a double using a UNumberFormat according to the UNumberFormat's locale, and initialize a UFieldPositionIterator that enumerates the subcomponents of the resulting string.

Parameters
formatThe formatter to use.
numberThe number to format.
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengthThe maximum size of result.
fpositerA pointer to a UFieldPositionIterator created by ufieldpositer_open (may be NULL if field position information is not needed, but in this case it's preferable to use unum_formatDouble). Iteration information already present in the UFieldPositionIterator is deleted, and the iterator is reset to apply to the fields in the formatted string created by this function call. The field values and indexes returned by ufieldpositer_next represent fields denoted by the UNumberFormatFields enum. Fields are not returned in a guaranteed order. Fields cannot overlap, but they may nest. For example, 1234 could format as "1,234" which might consist of a grouping separator field for ',' and an integer field encompassing the entire string.
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_formatDouble
unum_parse
unum_parseDouble
UFieldPositionIterator
UNumberFormatFields @stable ICU 59

Definition at line 256 of file unum.cpp.

References format, NULL, res, check-static-inits::result, status, U_FAILURE, and U_ILLEGAL_ARGUMENT_ERROR.

◆ unum_formatInt64_68()

int32_t unum_formatInt64_68 ( const UNumberFormat fmt,
int64_t  number,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format an int64 using a UNumberFormat. The int64 will be formatted according to the UNumberFormat's locale.

Parameters
fmtThe formatter to use.
numberThe number to format.
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengthThe maximum size of result.
posA pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case no field
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_format
unum_formatDouble
unum_parse
unum_parseInt64
unum_parseDouble
UFieldPosition @stable ICU 2.0

Definition at line 190 of file unum.cpp.

References fmt, fp, NULL, pos, res, check-static-inits::result, status, and U_FAILURE.

◆ unum_formatUFormattable_68()

int32_t unum_formatUFormattable_68 ( const UNumberFormat fmt,
const UFormattable number,
UChar result,
int32_t  resultLength,
UFieldPosition pos,
UErrorCode status 
)

Format a UFormattable into a string.

Parameters
fmtthe formatter to use
numberthe number to format, as a UFormattable
resultA pointer to a buffer to receive the NULL-terminated formatted number. If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
resultLengththe maximum number of UChars to write to result
posa pointer to a UFieldPosition. On input, position->field is read. On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. This parameter may be NULL, in which case it is ignored.
statusa pointer to an input-output UErrorCode
Returns
the total buffer size needed; if greater than resultLength, the output was truncated. Will return 0 on error.
See also
unum_parseToUFormattable @stable ICU 52

Definition at line 926 of file unum.cpp.

References fmt, fp, NULL, pos, res, check-static-inits::result, status, U_FAILURE, and U_ILLEGAL_ARGUMENT_ERROR.

◆ unum_getAttribute_68()

int32_t unum_getAttribute_68 ( const UNumberFormat fmt,
UNumberFormatAttribute  attr 
)

Get a numeric attribute associated with a UNumberFormat. An example of a numeric attribute is the number of integer digits a formatter will produce.

Parameters
fmtThe formatter to query.
attrThe attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE, UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS.
Returns
The value of attr.
See also
unum_setAttribute
unum_getDoubleAttribute
unum_setDoubleAttribute
unum_getTextAttribute
unum_setTextAttribute @stable ICU 2.0

Definition at line 512 of file unum.cpp.

References fmt, NULL, U_ZERO_ERROR, UNUM_FRACTION_DIGITS, UNUM_INTEGER_DIGITS, UNUM_LENIENT_PARSE, UNUM_MAX_FRACTION_DIGITS, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_MIN_INTEGER_DIGITS, and UNUM_ROUNDING_MODE.

◆ unum_getAvailable_68()

const char* unum_getAvailable_68 ( int32_t  localeIndex)

Get a locale for which decimal formatting patterns are available. A UNumberFormat in a locale returned by this function will perform the correct formatting and parsing for the locale. The results of this call are not valid for rule-based number formats.

Parameters
localeIndexThe index of the desired locale.
Returns
A locale for which number formatting patterns are available, or 0 if none.
See also
unum_countAvailable @stable ICU 2.0

Definition at line 500 of file unum.cpp.

References uloc_getAvailable.

◆ unum_getContext_68()

UDisplayContext unum_getContext_68 ( const UNumberFormat fmt,
UDisplayContextType  type,
UErrorCode status 
)

Get the formatter's UDisplayContext value for the specified UDisplayContextType, such as UDISPCTX_TYPE_CAPITALIZATION.

Parameters
fmtThe formatter to query.
typeThe UDisplayContextType whose value to return
statusA pointer to an UErrorCode to receive any errors
Returns
The UDisplayContextValue for the specified type. @stable ICU 53

Definition at line 893 of file unum.cpp.

References fmt, status, type, and U_FAILURE.

◆ unum_getDoubleAttribute_68()

double unum_getDoubleAttribute_68 ( const UNumberFormat fmt,
UNumberFormatAttribute  attr 
)

Get a numeric attribute associated with a UNumberFormat. An example of a numeric attribute is the number of integer digits a formatter will produce. If the formatter does not understand the attribute, -1 is returned.

Parameters
fmtThe formatter to query.
attrThe attribute to query; e.g. UNUM_ROUNDING_INCREMENT.
Returns
The value of attr.
See also
unum_getAttribute
unum_setAttribute
unum_setDoubleAttribute
unum_getTextAttribute
unum_setTextAttribute @stable ICU 2.0

Definition at line 598 of file unum.cpp.

References fmt, NULL, and UNUM_ROUNDING_INCREMENT.

◆ unum_getLocaleByType_68()

const char* unum_getLocaleByType_68 ( const UNumberFormat fmt,
ULocDataLocaleType  type,
UErrorCode status 
)

Get the locale for this number format object. You can choose between valid and actual locale.

Parameters
fmtThe formatter to get the locale from
typetype of the locale we're looking for (valid or actual)
statuserror code for the operation
Returns
the locale name @stable ICU 2.8

Definition at line 869 of file unum.cpp.

References fmt, NULL, status, type, U_ILLEGAL_ARGUMENT_ERROR, and U_SUCCESS.

◆ unum_getSymbol_68()

int32_t unum_getSymbol_68 ( const UNumberFormat fmt,
UNumberFormatSymbol  symbol,
UChar buffer,
int32_t  size,
UErrorCode status 
)

Get a symbol associated with a UNumberFormat. A UNumberFormat uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.

Parameters
fmtThe formatter to query.
symbolThe UNumberFormatSymbol constant for the symbol to get
bufferThe string buffer that will receive the symbol string; if it is NULL, then only the length of the symbol is returned
sizeThe size of the string buffer
statusA pointer to an UErrorCode to receive any errors
Returns
The length of the symbol; the buffer is not modified if length>=size
See also
unum_setSymbol @stable ICU 2.0

Definition at line 778 of file unum.cpp.

References makealias::extract(), fmt, NULL, size, status, symbol, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, U_UNSUPPORTED_ERROR, and UNUM_FORMAT_SYMBOL_COUNT.

◆ unum_getTextAttribute_68()

int32_t unum_getTextAttribute_68 ( const UNumberFormat fmt,
UNumberFormatTextAttribute  tag,
UChar result,
int32_t  resultLength,
UErrorCode status 
)

Get a text attribute associated with a UNumberFormat. An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the status. Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RULESETS.

Parameters
fmtThe formatter to query.
tagThe attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE, UNUM_DEFAULT_RULESET, or UNUM_PUBLIC_RULESETS.
resultA pointer to a buffer to receive the attribute.
resultLengthThe maximum size of result.
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_setTextAttribute
unum_getAttribute
unum_setAttribute @stable ICU 2.0

Definition at line 623 of file unum.cpp.

References count, fmt, i, NULL, res, check-static-inits::result, status, U_ASSERT, U_FAILURE, U_UNSUPPORTED_ERROR, UNUM_CURRENCY_CODE, UNUM_DEFAULT_RULESET, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, and UNUM_PUBLIC_RULESETS.

◆ unum_open_68()

UNumberFormat* unum_open_68 ( UNumberFormatStyle  style,
const UChar pattern,
int32_t  patternLength,
const char *  locale,
UParseError parseErr,
UErrorCode status 
)

Create and return a new UNumberFormat for formatting and parsing numbers. A UNumberFormat may be used to format numbers by calling unum_format, and to parse numbers by calling unum_parse. The caller must call unum_close when done to release resources used by this object.

Parameters
styleThe type of number format to open: one of UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_SPELLOUT, UNUM_ORDINAL, UNUM_DURATION, UNUM_NUMBERING_SYSTEM, UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT. If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the number format is opened using the given pattern, which must conform to the syntax described in DecimalFormat or RuleBasedNumberFormat, respectively.

NOTE:: New users with are strongly encouraged to use unumf_openForSkeletonAndLocale instead of unum_open.

Parameters
patternA pattern specifying the format to use. This parameter is ignored unless the style is UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.
patternLengthThe number of characters in the pattern, or -1 if null-terminated. This parameter is ignored unless the style is UNUM_PATTERN.
localeA locale identifier to use to determine formatting and parsing conventions, or NULL to use the default locale.
parseErrA pointer to a UParseError struct to receive the details of any parsing errors, or NULL if no parsing error details are desired.
statusA pointer to an input-output UErrorCode.
Returns
A pointer to a newly created UNumberFormat, or NULL if an error occurred.
See also
unum_close
DecimalFormat @stable ICU 2.0

Definition at line 41 of file unum.cpp.

References locale, NULL, pat, patternLength, status, style, U_FAILURE, U_MEMORY_ALLOCATION_ERROR, U_SUCCESS, U_UNSUPPORTED_ERROR, UNUM_CASH_CURRENCY, UNUM_CURRENCY, UNUM_CURRENCY_ACCOUNTING, UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_CURRENCY_STANDARD, UNUM_DECIMAL, UNUM_DECIMAL_COMPACT_LONG, UNUM_DECIMAL_COMPACT_SHORT, UNUM_DURATION, UNUM_LONG, UNUM_NUMBERING_SYSTEM, UNUM_ORDINAL, UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_SHORT, and UNUM_SPELLOUT.

◆ unum_parse_68()

int32_t unum_parse_68 ( const UNumberFormat fmt,
const UChar text,
int32_t  textLength,
int32_t parsePos,
UErrorCode status 
)

Parse a string into an integer using a UNumberFormat. The string will be parsed according to the UNumberFormat's locale. Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT and UNUM_DECIMAL_COMPACT_LONG.

Parameters
fmtThe formatter to use.
textThe text to parse.
textLengthThe length of text, or -1 if null-terminated.
parsePosIf not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. If not NULL, on output the offset at which parsing ended.
statusA pointer to an UErrorCode to receive any errors
Returns
The value of the parsed integer
See also
unum_parseInt64
unum_parseDouble
unum_format
unum_formatInt64
unum_formatDouble @stable ICU 2.0

Definition at line 395 of file unum.cpp.

References fmt, parseRes(), res, and status.

◆ unum_parseDecimal_68()

int32_t unum_parseDecimal_68 ( const UNumberFormat fmt,
const UChar text,
int32_t  textLength,
int32_t parsePos,
char *  outBuf,
int32_t  outBufLength,
UErrorCode status 
)

Parse a number from a string into an unformatted numeric string using a UNumberFormat. The input string will be parsed according to the UNumberFormat's locale. The syntax of the output is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT and UNUM_DECIMAL_COMPACT_LONG.

Parameters
fmtThe formatter to use.
textThe text to parse.
textLengthThe length of text, or -1 if null-terminated.
parsePosIf not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. If not NULL, on output the offset at which parsing ended.
outBufA (char *) buffer to receive the parsed number as a string. The output string will be nul-terminated if there is sufficient space.
outBufLengthThe size of the output buffer. May be zero, in which case the outBuf pointer may be NULL, and the function will return the size of the output string.
statusA pointer to an UErrorCode to receive any errors
Returns
the length of the output string, not including any terminating nul.
See also
unum_parse
unum_parseInt64
unum_format
unum_formatInt64
unum_formatDouble @stable ICU 4.4

Definition at line 431 of file unum.cpp.

References fmt, NULL, parseRes(), res, sp, status, U_ASSERT, U_BUFFER_OVERFLOW_ERROR, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, U_STRING_NOT_TERMINATED_WARNING, uprv_strcpy, and uprv_strncpy.

◆ unum_parseDouble_68()

double unum_parseDouble_68 ( const UNumberFormat fmt,
const UChar text,
int32_t  textLength,
int32_t parsePos,
UErrorCode status 
)

Parse a string into a double using a UNumberFormat. The string will be parsed according to the UNumberFormat's locale. Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT and UNUM_DECIMAL_COMPACT_LONG.

Parameters
fmtThe formatter to use.
textThe text to parse.
textLengthThe length of text, or -1 if null-terminated.
parsePosIf not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. If not NULL, on output the offset at which parsing ended.
statusA pointer to an UErrorCode to receive any errors
Returns
The value of the parsed double
See also
unum_parse
unum_parseInt64
unum_format
unum_formatInt64
unum_formatDouble @stable ICU 2.0

Definition at line 419 of file unum.cpp.

References fmt, parseRes(), res, and status.

◆ unum_parseDoubleCurrency_68()

double unum_parseDoubleCurrency_68 ( const UNumberFormat fmt,
const UChar text,
int32_t  textLength,
int32_t parsePos,
UChar currency,
UErrorCode status 
)

Parse a string into a double and a currency using a UNumberFormat. The string will be parsed according to the UNumberFormat's locale.

Parameters
fmtthe formatter to use
textthe text to parse
textLengththe length of text, or -1 if null-terminated
parsePosa pointer to an offset index into text at which to begin parsing. On output, *parsePos will point after the last parsed character. This parameter may be NULL, in which case parsing begins at offset 0.
currencya pointer to the buffer to receive the parsed null- terminated currency. This buffer must have a capacity of at least 4 UChars.
statusa pointer to an input-output UErrorCode
Returns
the parsed double
See also
unum_parseDouble
unum_formatDoubleCurrency @stable ICU 3.0

Definition at line 464 of file unum.cpp.

References fmt, NULL, pp, link_confs::src, status, U_FAILURE, U_PARSE_ERROR, u_strcpy, and U_ZERO_ERROR.

◆ unum_parseInt64_68()

int64_t unum_parseInt64_68 ( const UNumberFormat fmt,
const UChar text,
int32_t  textLength,
int32_t parsePos,
UErrorCode status 
)

Parse a string into an int64 using a UNumberFormat. The string will be parsed according to the UNumberFormat's locale. Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT and UNUM_DECIMAL_COMPACT_LONG.

Parameters
fmtThe formatter to use.
textThe text to parse.
textLengthThe length of text, or -1 if null-terminated.
parsePosIf not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. If not NULL, on output the offset at which parsing ended.
statusA pointer to an UErrorCode to receive any errors
Returns
The value of the parsed integer
See also
unum_parse
unum_parseDouble
unum_format
unum_formatInt64
unum_formatDouble @stable ICU 2.8

Definition at line 407 of file unum.cpp.

References fmt, parseRes(), res, and status.

◆ unum_parseToUFormattable_68()

UFormattable* unum_parseToUFormattable_68 ( const UNumberFormat fmt,
UFormattable result,
const UChar text,
int32_t  textLength,
int32_t parsePos,
UErrorCode status 
)

Parse a UChar string into a UFormattable. Example code:

Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT and UNUM_DECIMAL_COMPACT_LONG.

Parameters
fmtthe formatter to use
resultthe UFormattable to hold the result. If NULL, a new UFormattable will be allocated (which the caller must close with ufmt_close).
textthe text to parse
textLengththe length of text, or -1 if null-terminated
parsePosa pointer to an offset index into text at which to begin parsing. On output, *parsePos will point after the last parsed character. This parameter may be NULL in which case parsing begins at offset 0.
statusa pointer to an input-output UErrorCode
Returns
the UFormattable. Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable.
See also
ufmt_getType
ufmt_close @stable ICU 52

Definition at line 902 of file unum.cpp.

References fmt, NULL, parseRes(), check-static-inits::result, status, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, ufmt_close, and ufmt_open.

◆ unum_setAttribute_68()

void unum_setAttribute_68 ( UNumberFormat fmt,
UNumberFormatAttribute  attr,
int32_t  newValue 
)

Set a numeric attribute associated with a UNumberFormat. An example of a numeric attribute is the number of integer digits a formatter will produce. If the formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand the lenient-parse attribute.

Parameters
fmtThe formatter to set.
attrThe attribute to set; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE, UNUM_LENIENT_PARSE, UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS.
newValueThe new value of attr.
See also
unum_getAttribute
unum_getDoubleAttribute
unum_setDoubleAttribute
unum_getTextAttribute
unum_setTextAttribute @stable ICU 2.0

Definition at line 555 of file unum.cpp.

References fmt, NULL, U_ZERO_ERROR, UNUM_FRACTION_DIGITS, UNUM_INTEGER_DIGITS, UNUM_LENIENT_PARSE, UNUM_MAX_FRACTION_DIGITS, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_MIN_INTEGER_DIGITS, and UNUM_ROUNDING_MODE.

◆ unum_setContext_68()

void unum_setContext_68 ( UNumberFormat fmt,
UDisplayContext  value,
UErrorCode status 
)

Set a particular UDisplayContext value in the formatter, such as UDISPCTX_CAPITALIZATION_FOR_STANDALONE.

Parameters
fmtThe formatter for which to set a UDisplayContext value.
valueThe UDisplayContext value to set.
statusA pointer to an UErrorCode to receive any errors @stable ICU 53

Definition at line 883 of file unum.cpp.

References fmt, status, and U_FAILURE.

◆ unum_setDoubleAttribute_68()

void unum_setDoubleAttribute_68 ( UNumberFormat fmt,
UNumberFormatAttribute  attr,
double  newValue 
)

Set a numeric attribute associated with a UNumberFormat. An example of a numeric attribute is the number of integer digits a formatter will produce. If the formatter does not understand the attribute, this call is ignored.

Parameters
fmtThe formatter to set.
attrThe attribute to set; e.g. UNUM_ROUNDING_INCREMENT.
newValueThe new value of attr.
See also
unum_getAttribute
unum_setAttribute
unum_getDoubleAttribute
unum_getTextAttribute
unum_setTextAttribute @stable ICU 2.0

Definition at line 611 of file unum.cpp.

References fmt, NULL, and UNUM_ROUNDING_INCREMENT.

◆ unum_setSymbol_68()

void unum_setSymbol_68 ( UNumberFormat fmt,
UNumberFormatSymbol  symbol,
const UChar value,
int32_t  length,
UErrorCode status 
)

Set a symbol associated with a UNumberFormat. A UNumberFormat uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.

Parameters
fmtThe formatter to set.
symbolThe UNumberFormatSymbol constant for the symbol to set
valueThe string to set the symbol to
lengthThe length of the string, or -1 for a zero-terminated string
statusA pointer to an UErrorCode to receive any errors.
See also
unum_getSymbol @stable ICU 2.0

Definition at line 805 of file unum.cpp.

References fmt, length, NULL, status, symbol, gen-def::symbols, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, U_UNSUPPORTED_ERROR, and UNUM_FORMAT_SYMBOL_COUNT.

◆ unum_setTextAttribute_68()

void unum_setTextAttribute_68 ( UNumberFormat fmt,
UNumberFormatTextAttribute  tag,
const UChar newValue,
int32_t  newValueLength,
UErrorCode status 
)

Set a text attribute associated with a UNumberFormat. An example of a text attribute is the suffix for positive numbers. Rule-based formatters only understand UNUM_DEFAULT_RULESET.

Parameters
fmtThe formatter to set.
tagThe attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE, or UNUM_DEFAULT_RULESET.
newValueThe new value of attr.
newValueLengthThe length of newValue, or -1 if null-terminated.
statusA pointer to an UErrorCode to receive any errors
See also
unum_getTextAttribute
unum_getAttribute
unum_setAttribute @stable ICU 2.0

Definition at line 692 of file unum.cpp.

References fmt, NULL, status, U_ASSERT, U_FAILURE, U_UNSUPPORTED_ERROR, UNUM_CURRENCY_CODE, UNUM_DEFAULT_RULESET, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, and val.

◆ unum_toPattern_68()

int32_t unum_toPattern_68 ( const UNumberFormat fmt,
UBool  isPatternLocalized,
UChar result,
int32_t  resultLength,
UErrorCode status 
)

Extract the pattern from a UNumberFormat. The pattern will follow the DecimalFormat pattern syntax.

Parameters
fmtThe formatter to query.
isPatternLocalizedtrue if the pattern should be localized, false otherwise. This is ignored if the formatter is a rule-based formatter.
resultA pointer to a buffer to receive the pattern.
resultLengthThe maximum size of result.
statusA pointer to an input-output UErrorCode.
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
See also
unum_applyPattern
DecimalFormat @stable ICU 2.0

Definition at line 746 of file unum.cpp.

References fmt, NULL, pat, check-static-inits::result, status, U_ASSERT, and U_FAILURE.