Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

unum.h File Reference

C API: NumberFormat. More...

#include "unicode/utypes.h"
#include "unicode/umisc.h"

Go to the source code of this file.

Compounds

struct  UNumberFormatSymbols

Defines

#define UNFSYMBOLSMAXSIZE   10

Typedefs

typedef void* UNumberFormat
 A number formatter. More...

typedef enum UNumberFormatStyle UNumberFormatStyle
typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode
typedef enum UNumberFormatPadPosition UNumberFormatPadPosition
typedef enum UNumberFormatAttribute UNumberFormatAttribute
typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute
typedef struct UNumberFormatSymbols UNumberFormatSymbols
typedef enum UNumberFormatSymbol UNumberFormatSymbol

Enumerations

enum  UNumberFormatStyle {
  UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SPELLOUT,
  UNUM_DEFAULT = UNUM_DECIMAL
}
 The possible number format styles. More...

enum  UNumberFormatRoundingMode {
  UNUM_ROUND_CEILING, UNUM_ROUND_FLOOR, UNUM_ROUND_DOWN, UNUM_ROUND_UP,
  UNUM_FOUND_HALFEVEN, UNUM_ROUND_HALFDOWN, UNUM_ROUND_HALFUP
}
enum  UNumberFormatPadPosition { UNUM_PAD_BEFORE_PREFIX, UNUM_PAD_AFTER_PREFIX, UNUM_PAD_BEFORE_SUFFIX, UNUM_PAD_AFTER_SUFFIX }
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
}
 The possible UNumberFormat numeric attributes. More...

enum  UNumberFormatTextAttribute {
  UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX,
  UNUM_PADDING_CHARACTER
}
 The possible UNumberFormat text attributes. More...

enum  UNumberFormatSymbol {
  UNUM_DECIMAL_SEPARATOR_SYMBOL, UNUM_GROUPING_SEPARATOR_SYMBOL, UNUM_PATTERN_SEPARATOR_SYMBOL, UNUM_PERCENT_SYMBOL,
  UNUM_ZERO_DIGIT_SYMBOL, UNUM_DIGIT_SYMBOL, UNUM_MINUS_SIGN_SYMBOL, UNUM_PLUS_SIGN_SYMBOL,
  UNUM_CURRENCY_SYMBOL, UNUM_INTL_CURRENCY_SYMBOL, UNUM_MONETARY_SEPARATOR_SYMBOL, UNUM_EXPONENTIAL_SYMBOL,
  UNUM_PERMILL_SYMBOL, UNUM_PAD_ESCAPE_SYMBOL, UNUM_INFINITY_SYMBOL, UNUM_NAN_SYMBOL,
  UNUM_FORMAT_SYMBOL_COUNT
}
 Constants for specifying a number format symbol. More...


Functions

U_CAPI UNumberFormatunum_open (UNumberFormatStyle style, const char* locale, UErrorCode* status)
 Open a new UNumberFormat for formatting and parsing numbers. More...

U_CAPI UNumberFormatunum_openPattern ( const UChar* pattern, int32_t patternLength, const char* locale, UErrorCode* status)
 Open a new UNumberFormat for formatting and parsing numbers. More...

U_CAPI void unum_close (UNumberFormat* fmt)
 Close a UNumberFormat. More...

U_CAPI UNumberFormatunum_clone (const UNumberFormat *fmt, UErrorCode *status)
 Open a copy of a UNumberFormat. More...

U_CAPI int32_t unum_format ( const UNumberFormat* fmt, int32_t number, UChar* result, int32_t resultLength, UFieldPosition *pos, UErrorCode* status)
 Format an integer using a UNumberFormat. More...

U_CAPI int32_t unum_formatDouble ( const UNumberFormat* fmt, double number, UChar* result, int32_t resultLength, UFieldPosition *pos, UErrorCode* status)
 Format a double using a UNumberFormat. More...

U_CAPI int32_t unum_parse ( const UNumberFormat* fmt, const UChar* text, int32_t textLength, int32_t *parsePos , UErrorCode *status)
 Parse a string into an integer using a UNumberFormat. More...

U_CAPI double unum_parseDouble ( const UNumberFormat* fmt, const UChar* text, int32_t textLength, int32_t *parsePos , UErrorCode *status)
 Parse a string into a double using a UNumberFormat. More...

U_CAPI void unum_applyPattern ( UNumberFormat *format, UBool localized, const UChar *pattern, int32_t patternLength)
 Set the pattern used by an UNumberFormat. More...

U_CAPI const char* unum_getAvailable (int32_t index)
 Get a locale for which number formatting patterns are available. More...

U_CAPI int32_t unum_countAvailable (void)
 Determine how many locales have number formatting patterns available. More...

U_CAPI int32_t unum_getAttribute (const UNumberFormat* fmt, UNumberFormatAttribute attr)
 Get a numeric attribute associated with a UNumberFormat. More...

U_CAPI void unum_setAttribute ( UNumberFormat* fmt, UNumberFormatAttribute attr, int32_t newValue)
 Set a numeric attribute associated with a UNumberFormat. More...

U_CAPI double unum_getDoubleAttribute (const UNumberFormat* fmt, UNumberFormatAttribute attr)
 Get a numeric attribute associated with a UNumberFormat. More...

U_CAPI void unum_setDoubleAttribute ( UNumberFormat* fmt, UNumberFormatAttribute attr, double newValue)
 Set a numeric attribute associated with a UNumberFormat. More...

U_CAPI int32_t unum_getTextAttribute ( const UNumberFormat* fmt, UNumberFormatTextAttribute tag, UChar* result, int32_t resultLength, UErrorCode* status)
 Get a text attribute associated with a UNumberFormat. More...

U_CAPI void unum_setTextAttribute ( UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, int32_t newValueLength, UErrorCode *status)
 Set a text attribute associated with a UNumberFormat. More...

U_CAPI int32_t unum_toPattern ( const UNumberFormat* fmt, UBool isPatternLocalized, UChar* result, int32_t resultLength, UErrorCode* status)
 Extract the pattern from a UNumberFormat. More...

U_CAPI void unum_getSymbols ( const UNumberFormat *fmt, UNumberFormatSymbols *syms)
 Get the symbols associated with a UNumberFormat. More...

U_CAPI void unum_setSymbols ( UNumberFormat* fmt, const UNumberFormatSymbols* symbolsToSet, UErrorCode *status)
 Set the symbols associated with a UNumberFormat. More...

U_CAPI int32_t U_EXPORT2 unum_getSymbol (UNumberFormat *fmt, UNumberFormatSymbol symbol, UChar *buffer, int32_t size, UErrorCode *status)
 Get a symbol associated with a UNumberFormat. More...

U_CAPI void U_EXPORT2 unum_setSymbol (UNumberFormat *fmt, UNumberFormatSymbol symbol, const UChar *value, int32_t length, UErrorCode *status)
 Set a symbol associated with a UNumberFormat. More...


Detailed Description

C API: NumberFormat.

Number Format C API

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;
    UErrorCode success = U_ZERO_ERROR;
    UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
    unum_formatDouble(nf, myNumber, myString, u_strlen(myString), NULL, &status);
    printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
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.
 
     UChar* myString;
     int32_t i, resultlength, reslenneeded;
     UErrorCode success = U_ZERO_ERROR;
     int32_t a[] = { 123, 3333, -1234567 };
     const int32_t a_len = sizeof(a) / sizeof(a[0]);
     UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
     for (i = 0; i < a_len; i++) {
     resultlength=0;
     reslenneeded=unum_format(nf, a[i], NULL, resultlength, NULL, &status);
     if(status==U_BUFFER_OVERFLOW_ERROR){
         status=U_ZERO_ERROR;
         resultlength=resultlengthneeded+1;
         result=(UChar*)malloc(sizeof(UChar) * resultlength);
         unum_format(nf, a[i], result, resultlength, NULL, &status);
     }
     printf(" Example 2: %s\n", austrdup(result) );
     free(result);
     }
To format a number for a different Locale, specify it in the call to unum_open().
 
     UNumberFormat* nf = unum_open(UNUM_DEFAULT, "fr_FR", &success)
You can use a NumberFormat API unum_parse() to parse.
 
    UErrorCode success;
    int32_t pos=0;
    unum_parse(nf, result, u_strlen(result), &pos, &success);
Use UCAL_DECIMAL to get the normal number format for that country. There are other static options available. Use UCAL_CURRENCY to get the currency number format for that country. Use UCAL_PERCENT to get a format for displaying percentages. With this format, a fraction from 0.53 is displayed as 53%.

You can also control the display of numbers with such function as unum_getAttribues() and unum_setAtributes(). where in you can set the miminum fraction digits, grouping used 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:

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

Definition in file unum.h.


Define Documentation

#define UNFSYMBOLSMAXSIZE   10
 

Definition at line 546 of file unum.h.


Typedef Documentation

typedef void* UNumberFormat
 

A number formatter.

For usage in C programs.

Definition at line 114 of file unum.h.

typedef enum UNumberFormatAttribute UNumberFormatAttribute
 

Definition at line 379 of file unum.h.

typedef enum UNumberFormatPadPosition UNumberFormatPadPosition
 

Definition at line 148 of file unum.h.

typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode
 

Definition at line 140 of file unum.h.

typedef enum UNumberFormatStyle UNumberFormatStyle
 

Definition at line 129 of file unum.h.

typedef enum UNumberFormatSymbol UNumberFormatSymbol
 

Definition at line 655 of file unum.h.

typedef struct UNumberFormatSymbols UNumberFormatSymbols
 

Definition at line 585 of file unum.h.

typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute
 

Definition at line 482 of file unum.h.


Enumeration Type Documentation

enum UNumberFormatAttribute
 

The possible UNumberFormat numeric attributes.

Enumeration values:
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.

Definition at line 345 of file unum.h.

enum UNumberFormatPadPosition
 

Enumeration values:
UNUM_PAD_BEFORE_PREFIX  
UNUM_PAD_AFTER_PREFIX  
UNUM_PAD_BEFORE_SUFFIX  
UNUM_PAD_AFTER_SUFFIX  

Definition at line 142 of file unum.h.

enum UNumberFormatRoundingMode
 

Enumeration values:
UNUM_ROUND_CEILING  
UNUM_ROUND_FLOOR  
UNUM_ROUND_DOWN  
UNUM_ROUND_UP  
UNUM_FOUND_HALFEVEN  
UNUM_ROUND_HALFDOWN  
UNUM_ROUND_HALFUP  

Definition at line 131 of file unum.h.

enum UNumberFormatStyle
 

The possible number format styles.

Enumeration values:
UNUM_DECIMAL   Decimal format.
UNUM_CURRENCY   Currency format.
UNUM_PERCENT   Percent format.
UNUM_SPELLOUT   Spellout format.
UNUM_DEFAULT   Default format.

Definition at line 117 of file unum.h.

enum UNumberFormatSymbol
 

Constants for specifying a number format symbol.

Draft:
Enumeration values:
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_FORMAT_SYMBOL_COUNT   count symbol constants.

Definition at line 619 of file unum.h.

enum UNumberFormatTextAttribute
 

The possible UNumberFormat text attributes.

Enumeration values:
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.

Definition at line 470 of file unum.h.


Function Documentation

U_CAPI void unum_applyPattern ( UNumberFormat * format,
UBool localized,
const UChar * pattern,
int32_t patternLength )
 

Set the pattern used by an UNumberFormat.

The pattern should follow the pattern syntax rules.

Parameters:
fmt   The formatter to set.
localized   TRUE if the pattern is localized, FALSE otherwise.
pattern   The new pattern
patternLength   The length of pattern, or -1 if null-terminated.
See also:
unum_toPattern
Draft:

U_CAPI UNumberFormat * unum_clone ( const UNumberFormat * fmt,
UErrorCode * status )
 

Open a copy of a UNumberFormat.

This function performs a deep copy.

Parameters:
fmt   The format to copy
status   A pointer to an UErrorCode to receive any errors.
Returns:
A pointer to a UNumberFormat identical to fmt.
Stable:

U_CAPI void unum_close ( UNumberFormat * fmt )
 

Close a UNumberFormat.

Once closed, a UNumberFormat may no longer be used.

Parameters:
fmt   The formatter to close.
Stable:

U_CAPI int32_t unum_countAvailable ( void )
 

Determine how many locales have number formatting patterns available.

This function is most useful as determining the loop ending condition for calls to \Ref{unum_getAvailable}.

Returns:
The number of locales for which number formatting patterns are available.
See also:
unum_getAvailable
Stable:

U_CAPI int32_t unum_format ( 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:
fmt   The formatter to use.
number   The number to format.
result   A pointer to a buffer to receive the formatted number.
resultLength   The maximum size of result.
position   A 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
status   A 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 , UFieldPosition
Draft:

U_CAPI int32_t unum_formatDouble ( 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:
fmt   The formatter to use.
number   The number to format.
result   A pointer to a buffer to receive the formatted number.
resultLength   The maximum size of result.
position   A 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
status   A 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_parse , unum_parseDouble , UFieldPosition
Draft:

U_CAPI int32_t unum_getAttribute ( 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:
fmt   The formatter to query.
attr   The 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.
Returns:
The value of attr.
See also:
unum_setAttribute , unum_getDoubleAttribute , unum_setDoubleAttribute , unum_getTextAttribute , unum_setTextAttribute
Stable:

U_CAPI const char * unum_getAvailable ( int32_t index )
 

Get a locale for which number formatting patterns are available.

A UNumberFormat in a locale returned by this function will perform the correct formatting and parsing for the locale.

Parameters:
index   The index of the desired locale.
Returns:
A locale for which number formatting patterns are available, or 0 if none.
See also:
unum_countAvailable
Stable:

U_CAPI double unum_getDoubleAttribute ( 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:
fmt   The formatter to query.
attr   The 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:

U_CAPI int32_t U_EXPORT2 unum_getSymbol ( 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.

Parameters:
fmt   The formatter to query.
symbol   The UNumberFormatSymbol constant for the symbol to get
buffer   The string buffer that will receive the symbol string; if it is NULL, then only the length of the symbol is returned
size   The size of the string buffer
Returns:
The length of the symbol; the buffer is not modified if length>=size
See also:
unum_setSymbol
Draft:

U_CAPI void unum_getSymbols ( const UNumberFormat * fmt,
UNumberFormatSymbols * syms )
 

Get the symbols associated with a UNumberFormat.

A UNumberFormat uses symbols to represent the special locale-dependent characters in a number, for example the percent sign.

Parameters:
fmt   The formatter to query.
syms   A pointer to a UNumberFormatSymbols to receive the symbols associated with fmt.
See also:
unum_setSymbols
Deprecated:
remove after 2000-dec-31. See UNumberFormatSymbol and unum_getSymbol() for a replacement.

U_CAPI int32_t unum_getTextAttribute ( 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.

Parameters:
fmt   The formatter to query.
attr   The attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX
result   A pointer to a buffer to receive the attribute.
resultLength   The maximum size of result.
status   A 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
Draft:

U_CAPI UNumberFormat * unum_open ( UNumberFormatStyle style,
const char * locale,
UErrorCode * status )
 

Open a new UNumberFormat for formatting and parsing numbers.

A UNumberFormat may be used to format numbers in calls to \Ref{unum_format}, and to parse numbers in calls to \Ref{unum_parse}.

Parameters:
style   The type of number format to open: one of UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SPELLOUT, or UNUM_DEFAULT
locale   The locale specifying the formatting conventions
status   A pointer to an UErrorCode to receive any errors
Returns:
A pointer to a UNumberFormat to use for formatting numbers, or 0 if an error occurred.
See also:
unum_openPattern
Stable:

U_CAPI UNumberFormat * unum_openPattern ( const UChar * pattern,
int32_t patternLength,
const char * locale,
UErrorCode * status )
 

Open a new UNumberFormat for formatting and parsing numbers.

A UNumberFormat may be used to format numbers in calls to \Ref{unum_format}, and to parse numbers in calls to \Ref{unum_parse}.

Parameters:
pattern   A pattern specifying the format to use.
patternLength   The number of characters in the pattern, or -1 if null-terminated.
locale   The locale specifying the formatting conventions
status   A pointer to an UErrorCode to receive any errors
Returns:
A pointer to a UNumberFormat to use for formatting numbers, or 0 if an error occurred.
See also:
unum_open
Draft:

U_CAPI int32_t unum_parse ( 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.

Parameters:
fmt   The formatter to use.
text   The text to parse.
textLength   The length of text, or -1 if null-terminated.
parsePos   If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. If not 0, on output the offset at which parsing ended.
status   A pointer to an UErrorCode to receive any errors
Returns:
The value of the parsed integer
See also:
unum_parseDouble , unum_format , unum_formatDouble
Draft:

U_CAPI double unum_parseDouble ( 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.

Parameters:
fmt   The formatter to use.
text   The text to parse.
textLength   The length of text, or -1 if null-terminated.
parsePos   If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. If not 0, on output the offset at which parsing ended.
status   A pointer to an UErrorCode to receive any errors
Returns:
The value of the parsed double
See also:
unum_parse , unum_format , unum_formatDouble
Draft:

U_CAPI void unum_setAttribute ( 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.

Parameters:
fmt   The formatter to set.
attr   The 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.
newValue   The new value of attr.
See also:
unum_getAttribute , unum_getDoubleAttribute , unum_setDoubleAttribute , unum_getTextAttribute , unum_setTextAttribute
Stable:

U_CAPI void unum_setDoubleAttribute ( 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.

Parameters:
fmt   The formatter to set.
attr   The attribute to set; e.g. UNUM_ROUNDING_INCREMENT.
newValue   The new value of attr.
See also:
unum_getAttribute , unum_setAttribute , unum_getDoubleAttribute , unum_getTextAttribute , unum_setTextAttribute
Stable:

U_CAPI void U_EXPORT2 unum_setSymbol ( 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.

Parameters:
fmt   The formatter to set.
symbol   The UNumberFormatSymbol constant for the symbol to set
value   The string to set the symbol to
length   The length of the string, or -1 for a zero-terminated string
status   A pointer to an UErrorCode to receive any errors.
See also:
unum_getSymbol
Draft:

U_CAPI void unum_setSymbols ( UNumberFormat * fmt,
const UNumberFormatSymbols * symbolsToSet,
UErrorCode * status )
 

Set the symbols associated with a UNumberFormat.

A UNumberFormat uses symbols to represent the special locale-dependent characters in a number, for example the percent sign.

Parameters:
fmt   The formatter to set.
symbolsToSet   The UNumberFormatSymbols to associate with fmt.
status   A pointer to an UErrorCode to receive any errors.
See also:
unum_getSymbols
Deprecated:
remove after 2000-dec-31. See UNumberFormatSymbol and unum_getSymbol() for a replacement.

U_CAPI void unum_setTextAttribute ( 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.

Parameters:
fmt   The formatter to set.
attr   The attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX
newValue   The new value of attr.
newValueLength   The length of newValue, or -1 if null-terminated.
status   A pointer to an UErrorCode to receive any errors
See also:
unum_getTextAttribute , unum_getAttribute , unum_setAttribute
Draft:

U_CAPI int32_t unum_toPattern ( const UNumberFormat * fmt,
UBool isPatternLocalized,
UChar * result,
int32_t resultLength,
UErrorCode * status )
 

Extract the pattern from a UNumberFormat.

The pattern will follow the pattern syntax.

Parameters:
fmt   The formatter to query.
isPatternLocalized   TRUE if the pattern should be localized, FALSE otherwise.
result   A pointer to a buffer to receive the pattern.
resultLength   The maximum size of result.
status   A pointer to an UErrorCode to receive any errors
Returns:
The total buffer size needed; if greater than resultLength, the output was truncated.
Draft:


Generated at Tue Jun 12 14:04:14 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000