indigo. icu.unum

Created12.05.2005
Last modified13.05.2005

Provides functions for formatting and parsing a number.

See the official documentation at http://icu.sourceforge.net- /apiref- /icu4c- /unum_8h.html.

Summary
A number formatter for usage in C programs.
The possible number format styles.
The possible number format rounding modes.
The possible number format pad positions.
Create and return a new UNumberFormat for formatting and parsing numbers.
Close an UNumberFormat.
Set a numeric attribute associated with a UNumberFormat.
Format the integer number using the UNumberFormat fmt.
Format the 64bit integer number using the UNumberFormat fmt.
Format the double number using the UNumberFormat fmt.
Parse a string into an integer using the UNumberFormat fmt.
Parse a string into a long integer using the UNumberFormat fmt.
Parse a string into a double using the UNumberFormat fmt.
This is the standard format for decimal values in the system locale.
This is the standard format for scientific values in the system locale.
This is the standard format for decimal values in the C/POSIX locale.
This is the standard format for scientific values in the C/POSIX locale.

Types

UNumberFormat

A number formatter for usage in C programs.  See unum_open().

Enumerations

UNumberFormatStyle

The possible number format styles.

UNumberFormatRoundingMode

The possible number format rounding modes.

UNumberFormatPadPosition

The possible number format pad positions.

Functions

unum_open()

UNumberFormat* function(UNumberFormatStyle style,
UChar *pat,
int32_t patLen,
char *locale,
UParseError *err,
UErrorCode *status) unum_open

Create and return a new UNumberFormat for formatting and parsing numbers.  An 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_SPELLOUT, 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.
patA pattern specifying the format to use.  This parameter is ignored unless the style is UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.
patLenThe 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.
errA 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.

See also unum_close().

unum_close()

void function(UNumberFormat *fmt) unum_close

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

unum_setAttribute()

void function(UNumberFormat *fmt,
UNumberFormatAttribute attr,
int32_t newValue) unum_setAttribute

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.

unum_format()

int32_t function(UNumberFormat *fmt,
int32_t number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_format

Format the integer number using the UNumberFormat fmt.  The integer will be formatted according to the UNumberFormat’s locale.  The string will be saved in result, with a maximum length of resultLength.  The function returns the length of the result.  Errors are saved in status, pos must be null.

unum_formatInt64()

int32_t function(UNumberFormat *fmt,
int64_t number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_formatInt64

Format the 64bit integer number using the UNumberFormat fmt.  The integer will be formatted according to the UNumberFormat’s locale.  The string will be saved in result, with a maximum length of resultLength.  The function returns the length of the result.  Errors are saved in status, pos must be null.

unum_formatDouble()

int32_t function(UNumberFormat *fmt,
double number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_formatDouble

Format the double number using the UNumberFormat fmt.  The integer will be formatted according to the UNumberFormat’s locale.  The string will be saved in result, with a maximum length of resultLength.  The function returns the length of the result.  Errors are saved in status, pos must be null.

unum_parse()

int32_t function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parse

Parse a string into an integer using the UNumberFormat fmt.  The string will be parsed according to the UNumberFormat’s locale.  Pass null for the parsePos.

unum_parseInt64()

int64_t function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parseInt64

Parse a string into a long integer using the UNumberFormat fmt.  The string will be parsed according to the UNumberFormat’s locale.  Pass null for the parsePos.

unum_parseDouble()

double function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parseDouble

Parse a string into a double using the UNumberFormat fmt.  The string will be parsed according to the UNumberFormat’s locale.  Pass null for the parsePos.

Variables

unum_stdDecimalFmt

public UNumberFormat* unum_stdDecimalFmt

This is the standard format for decimal values in the system locale.

unum_stdDecimalFmt

This is the standard format for scientific values in the system locale.

unum_stdDecimalFmt

This is the standard format for decimal values in the C/POSIX locale.

unum_stdDecimalFmt

This is the standard format for scientific values in the C/POSIX locale.

UNumberFormat* function(UNumberFormatStyle style,
UChar *pat,
int32_t patLen,
char *locale,
UParseError *err,
UErrorCode *status) unum_open
Create and return a new UNumberFormat for formatting and parsing numbers.
A number formatter for usage in C programs.
void function(UNumberFormat *fmt) unum_close
Close an UNumberFormat.
void function(UNumberFormat *fmt,
UNumberFormatAttribute attr,
int32_t newValue) unum_setAttribute
Set a numeric attribute associated with a UNumberFormat.
int32_t function(UNumberFormat *fmt,
int32_t number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_format
Format the integer number using the UNumberFormat fmt.
int32_t function(UNumberFormat *fmt,
int64_t number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_formatInt64
Format the 64bit integer number using the UNumberFormat fmt.
int32_t function(UNumberFormat *fmt,
double number,
UChar *result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode *status) unum_formatDouble
Format the double number using the UNumberFormat fmt.
int32_t function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parse
Parse a string into an integer using the UNumberFormat fmt.
int64_t function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parseInt64
Parse a string into a long integer using the UNumberFormat fmt.
double function(UNumberFormat *fmt,
UChar *text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status) unum_parseDouble
Parse a string into a double using the UNumberFormat fmt.
public UNumberFormat* unum_stdDecimalFmt
This is the standard format for decimal values in the system locale.