jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ******************************************************************************* jpayne@69: * Copyright (C) 1997-2015, International Business Machines Corporation and others. jpayne@69: * All Rights Reserved. jpayne@69: * Modification History: jpayne@69: * jpayne@69: * Date Name Description jpayne@69: * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes jpayne@69: ******************************************************************************* jpayne@69: */ jpayne@69: jpayne@69: #ifndef _UNUM jpayne@69: #define _UNUM jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if !UCONFIG_NO_FORMATTING jpayne@69: jpayne@69: #include "unicode/localpointer.h" jpayne@69: #include "unicode/uloc.h" jpayne@69: #include "unicode/ucurr.h" jpayne@69: #include "unicode/umisc.h" jpayne@69: #include "unicode/parseerr.h" jpayne@69: #include "unicode/uformattable.h" jpayne@69: #include "unicode/udisplaycontext.h" jpayne@69: #include "unicode/ufieldpositer.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: Compatibility APIs for number formatting. jpayne@69: * jpayne@69: *
IMPORTANT: New users with are strongly encouraged to jpayne@69: * see if unumberformatter.h fits their use case. Although not deprecated, jpayne@69: * this header is provided for backwards compatibility only. jpayne@69: * jpayne@69: * Number Format C API Provides functions for jpayne@69: * formatting and parsing a number. Also provides methods for jpayne@69: * determining which locales have number formats, and what their names jpayne@69: * are. jpayne@69: *
jpayne@69: * UNumberFormat helps you to format and parse numbers for any locale. jpayne@69: * Your code can be completely independent of the locale conventions jpayne@69: * for decimal points, thousands-separators, or even the particular jpayne@69: * decimal digits used, or whether the number format is even decimal. jpayne@69: * There are different number format styles like decimal, currency, jpayne@69: * percent and spellout. jpayne@69: *
jpayne@69: * To format a number for the current Locale, use one of the static jpayne@69: * factory methods: jpayne@69: *
jpayne@69: * \code jpayne@69: * UChar myString[20]; jpayne@69: * double myNumber = 7.0; jpayne@69: * UErrorCode status = U_ZERO_ERROR; jpayne@69: * UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status); jpayne@69: * unum_formatDouble(nf, myNumber, myString, 20, NULL, &status); jpayne@69: * printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*) jpayne@69: * \endcode jpayne@69: *jpayne@69: * If you are formatting multiple numbers, it is more efficient to get jpayne@69: * the format and use it multiple times so that the system doesn't jpayne@69: * have to fetch the information about the local language and country jpayne@69: * conventions multiple times. jpayne@69: *
jpayne@69: * \code jpayne@69: * uint32_t i, resultlength, reslenneeded; jpayne@69: * UErrorCode status = U_ZERO_ERROR; jpayne@69: * UFieldPosition pos; jpayne@69: * uint32_t a[] = { 123, 3333, -1234567 }; jpayne@69: * const uint32_t a_len = sizeof(a) / sizeof(a[0]); jpayne@69: * UNumberFormat* nf; jpayne@69: * UChar* result = NULL; jpayne@69: * jpayne@69: * nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status); jpayne@69: * for (i = 0; i < a_len; i++) { jpayne@69: * resultlength=0; jpayne@69: * reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status); jpayne@69: * result = NULL; jpayne@69: * if(status==U_BUFFER_OVERFLOW_ERROR){ jpayne@69: * status=U_ZERO_ERROR; jpayne@69: * resultlength=reslenneeded+1; jpayne@69: * result=(UChar*)malloc(sizeof(UChar) * resultlength); jpayne@69: * unum_format(nf, a[i], result, resultlength, &pos, &status); jpayne@69: * } jpayne@69: * printf( " Example 2: %s\n", austrdup(result)); jpayne@69: * free(result); jpayne@69: * } jpayne@69: * \endcode jpayne@69: *jpayne@69: * To format a number for a different Locale, specify it in the jpayne@69: * call to unum_open(). jpayne@69: *
jpayne@69: * \code jpayne@69: * UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, "fr_FR", NULL, &success) jpayne@69: * \endcode jpayne@69: *jpayne@69: * You can use a NumberFormat API unum_parse() to parse. jpayne@69: *
jpayne@69: * \code jpayne@69: * UErrorCode status = U_ZERO_ERROR; jpayne@69: * int32_t pos=0; jpayne@69: * int32_t num; jpayne@69: * num = unum_parse(nf, str, u_strlen(str), &pos, &status); jpayne@69: * \endcode jpayne@69: *jpayne@69: * Use UNUM_DECIMAL to get the normal number format for that country. jpayne@69: * There are other static options available. Use UNUM_CURRENCY jpayne@69: * to get the currency number format for that country. Use UNUM_PERCENT jpayne@69: * to get a format for displaying percentages. With this format, a jpayne@69: * fraction from 0.53 is displayed as 53%. jpayne@69: *
jpayne@69: * Use a pattern to create either a DecimalFormat or a RuleBasedNumberFormat jpayne@69: * formatter. The pattern must conform to the syntax defined for those jpayne@69: * formatters. jpayne@69: *
jpayne@69: * You can also control the display of numbers with such function as jpayne@69: * unum_getAttributes() and unum_setAttributes(), which let you set the jpayne@69: * minimum fraction digits, grouping, etc. jpayne@69: * @see UNumberFormatAttributes for more details jpayne@69: *
jpayne@69: * You can also use forms of the parse and format methods with jpayne@69: * ParsePosition and UFieldPosition to allow you to: jpayne@69: *
jpayne@69: * It is also possible to change or set the symbols used for a particular jpayne@69: * locale like the currency symbol, the grouping separator , monetary separator jpayne@69: * etc by making use of functions unum_setSymbols() and unum_getSymbols(). jpayne@69: */ jpayne@69: jpayne@69: /** A number formatter. jpayne@69: * For usage in C programs. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: typedef void* UNumberFormat; jpayne@69: jpayne@69: /** The possible number format styles. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: typedef enum UNumberFormatStyle { jpayne@69: /** jpayne@69: * Decimal format defined by a pattern string. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UNUM_PATTERN_DECIMAL=0, jpayne@69: /** jpayne@69: * Decimal format ("normal" style). jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UNUM_DECIMAL=1, jpayne@69: /** jpayne@69: * Currency format (generic). jpayne@69: * Defaults to UNUM_CURRENCY_STANDARD style jpayne@69: * (using currency symbol, e.g., "$1.00", with non-accounting jpayne@69: * style for negative values e.g. using minus sign). jpayne@69: * The specific style may be specified using the -cf- locale key. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UNUM_CURRENCY=2, jpayne@69: /** jpayne@69: * Percent format jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UNUM_PERCENT=3, jpayne@69: /** jpayne@69: * Scientific format jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: UNUM_SCIENTIFIC=4, jpayne@69: /** jpayne@69: * Spellout rule-based format. The default ruleset can be specified/changed using jpayne@69: * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets jpayne@69: * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UNUM_SPELLOUT=5, jpayne@69: /** jpayne@69: * Ordinal rule-based format . The default ruleset can be specified/changed using jpayne@69: * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets jpayne@69: * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UNUM_ORDINAL=6, jpayne@69: /** jpayne@69: * Duration rule-based format jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UNUM_DURATION=7, jpayne@69: /** jpayne@69: * Numbering system rule-based format jpayne@69: * @stable ICU 4.2 jpayne@69: */ jpayne@69: UNUM_NUMBERING_SYSTEM=8, jpayne@69: /** jpayne@69: * Rule-based format defined by a pattern string. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UNUM_PATTERN_RULEBASED=9, jpayne@69: /** jpayne@69: * Currency format with an ISO currency code, e.g., "USD1.00". jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: UNUM_CURRENCY_ISO=10, jpayne@69: /** jpayne@69: * Currency format with a pluralized currency name, jpayne@69: * e.g., "1.00 US dollar" and "3.00 US dollars". jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: UNUM_CURRENCY_PLURAL=11, jpayne@69: /** jpayne@69: * Currency format for accounting, e.g., "($3.00)" for jpayne@69: * negative currency amount instead of "-$3.00" ({@link #UNUM_CURRENCY}). jpayne@69: * Overrides any style specified using -cf- key in locale. jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: UNUM_CURRENCY_ACCOUNTING=12, jpayne@69: /** jpayne@69: * Currency format with a currency symbol given CASH usage, e.g., jpayne@69: * "NT$3" instead of "NT$3.23". jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UNUM_CASH_CURRENCY=13, jpayne@69: /** jpayne@69: * Decimal format expressed using compact notation jpayne@69: * (short form, corresponds to UNumberCompactStyle=UNUM_SHORT) jpayne@69: * e.g. "23K", "45B" jpayne@69: * @stable ICU 56 jpayne@69: */ jpayne@69: UNUM_DECIMAL_COMPACT_SHORT=14, jpayne@69: /** jpayne@69: * Decimal format expressed using compact notation jpayne@69: * (long form, corresponds to UNumberCompactStyle=UNUM_LONG) jpayne@69: * e.g. "23 thousand", "45 billion" jpayne@69: * @stable ICU 56 jpayne@69: */ jpayne@69: UNUM_DECIMAL_COMPACT_LONG=15, jpayne@69: /** jpayne@69: * Currency format with a currency symbol, e.g., "$1.00", jpayne@69: * using non-accounting style for negative values (e.g. minus sign). jpayne@69: * Overrides any style specified using -cf- key in locale. jpayne@69: * @stable ICU 56 jpayne@69: */ jpayne@69: UNUM_CURRENCY_STANDARD=16, jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * One more than the highest normal UNumberFormatStyle value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UNUM_FORMAT_STYLE_COUNT=17, jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: jpayne@69: /** jpayne@69: * Default format jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UNUM_DEFAULT = UNUM_DECIMAL, jpayne@69: /** jpayne@69: * Alias for UNUM_PATTERN_DECIMAL jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UNUM_IGNORE = UNUM_PATTERN_DECIMAL jpayne@69: } UNumberFormatStyle; jpayne@69: jpayne@69: /** The possible number format rounding modes. jpayne@69: * jpayne@69: *
jpayne@69: * For more detail on rounding modes, see: jpayne@69: * http://userguide.icu-project.org/formatparse/numbers/rounding-modes jpayne@69: * jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: typedef enum UNumberFormatRoundingMode { jpayne@69: UNUM_ROUND_CEILING, jpayne@69: UNUM_ROUND_FLOOR, jpayne@69: UNUM_ROUND_DOWN, jpayne@69: UNUM_ROUND_UP, jpayne@69: /** jpayne@69: * Half-even rounding jpayne@69: * @stable, ICU 3.8 jpayne@69: */ jpayne@69: UNUM_ROUND_HALFEVEN, jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * Half-even rounding, misspelled name jpayne@69: * @deprecated, ICU 3.8 jpayne@69: */ jpayne@69: UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN, jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1, jpayne@69: UNUM_ROUND_HALFUP, jpayne@69: /** jpayne@69: * ROUND_UNNECESSARY reports an error if formatted result is not exact. jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: UNUM_ROUND_UNNECESSARY jpayne@69: } UNumberFormatRoundingMode; jpayne@69: jpayne@69: /** The possible number format pad positions. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: typedef enum UNumberFormatPadPosition { jpayne@69: UNUM_PAD_BEFORE_PREFIX, jpayne@69: UNUM_PAD_AFTER_PREFIX, jpayne@69: UNUM_PAD_BEFORE_SUFFIX, jpayne@69: UNUM_PAD_AFTER_SUFFIX jpayne@69: } UNumberFormatPadPosition; jpayne@69: jpayne@69: /** jpayne@69: * Constants for specifying short or long format. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: typedef enum UNumberCompactStyle { jpayne@69: /** @stable ICU 51 */ jpayne@69: UNUM_SHORT, jpayne@69: /** @stable ICU 51 */ jpayne@69: UNUM_LONG jpayne@69: /** @stable ICU 51 */ jpayne@69: } UNumberCompactStyle; jpayne@69: jpayne@69: /** jpayne@69: * Constants for specifying currency spacing jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: enum UCurrencySpacing { jpayne@69: /** @stable ICU 4.8 */ jpayne@69: UNUM_CURRENCY_MATCH, jpayne@69: /** @stable ICU 4.8 */ jpayne@69: UNUM_CURRENCY_SURROUNDING_MATCH, jpayne@69: /** @stable ICU 4.8 */ jpayne@69: UNUM_CURRENCY_INSERT, jpayne@69: jpayne@69: /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, jpayne@69: * it is needed for layout of DecimalFormatSymbols object. */ jpayne@69: #ifndef U_FORCE_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * One more than the highest normal UCurrencySpacing value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UNUM_CURRENCY_SPACING_COUNT jpayne@69: #endif // U_FORCE_HIDE_DEPRECATED_API jpayne@69: }; jpayne@69: typedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */ jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selectors for format fields jpayne@69: * defined by NumberFormat and UNumberFormat. jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: typedef enum UNumberFormatFields { jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_INTEGER_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_FRACTION_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_DECIMAL_SEPARATOR_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_EXPONENT_SYMBOL_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_EXPONENT_SIGN_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_EXPONENT_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_GROUPING_SEPARATOR_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_CURRENCY_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_PERCENT_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_PERMILL_FIELD, jpayne@69: /** @stable ICU 49 */ jpayne@69: UNUM_SIGN_FIELD, jpayne@69: /** @stable ICU 64 */ jpayne@69: UNUM_MEASURE_UNIT_FIELD, jpayne@69: /** @stable ICU 64 */ jpayne@69: UNUM_COMPACT_FIELD, jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * One more than the highest normal UNumberFormatFields value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UNUM_FIELD_COUNT = UNUM_SIGN_FIELD + 3 jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: } UNumberFormatFields; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Create and return a new UNumberFormat for formatting and parsing jpayne@69: * numbers. A UNumberFormat may be used to format numbers by calling jpayne@69: * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }. jpayne@69: * The caller must call {@link #unum_close } when done to release resources jpayne@69: * used by this object. jpayne@69: * @param style The type of number format to open: one of jpayne@69: * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, jpayne@69: * UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_SPELLOUT, jpayne@69: * UNUM_ORDINAL, UNUM_DURATION, UNUM_NUMBERING_SYSTEM, jpayne@69: * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT. jpayne@69: * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the jpayne@69: * number format is opened using the given pattern, which must conform jpayne@69: * to the syntax described in DecimalFormat or RuleBasedNumberFormat, jpayne@69: * respectively. jpayne@69: * jpayne@69: *
NOTE:: New users with are strongly encouraged to
jpayne@69: * use unumf_openForSkeletonAndLocale instead of unum_open.
jpayne@69: *
jpayne@69: * @param pattern A pattern specifying the format to use.
jpayne@69: * This parameter is ignored unless the style is
jpayne@69: * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.
jpayne@69: * @param patternLength The number of characters in the pattern, or -1
jpayne@69: * if null-terminated. This parameter is ignored unless the style is
jpayne@69: * UNUM_PATTERN.
jpayne@69: * @param locale A locale identifier to use to determine formatting
jpayne@69: * and parsing conventions, or NULL to use the default locale.
jpayne@69: * @param parseErr A pointer to a UParseError struct to receive the
jpayne@69: * details of any parsing errors, or NULL if no parsing error details
jpayne@69: * are desired.
jpayne@69: * @param status A pointer to an input-output UErrorCode.
jpayne@69: * @return A pointer to a newly created UNumberFormat, or NULL if an
jpayne@69: * error occurred.
jpayne@69: * @see unum_close
jpayne@69: * @see DecimalFormat
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE UNumberFormat* U_EXPORT2
jpayne@69: unum_open( UNumberFormatStyle style,
jpayne@69: const UChar* pattern,
jpayne@69: int32_t patternLength,
jpayne@69: const char* locale,
jpayne@69: UParseError* parseErr,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Close a UNumberFormat.
jpayne@69: * Once closed, a UNumberFormat may no longer be used.
jpayne@69: * @param fmt The formatter to close.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_close(UNumberFormat* fmt);
jpayne@69:
jpayne@69: #if U_SHOW_CPLUSPLUS_API
jpayne@69:
jpayne@69: U_NAMESPACE_BEGIN
jpayne@69:
jpayne@69: /**
jpayne@69: * \class LocalUNumberFormatPointer
jpayne@69: * "Smart pointer" class, closes a UNumberFormat via unum_close().
jpayne@69: * For most methods see the LocalPointerBase base class.
jpayne@69: *
jpayne@69: * @see LocalPointerBase
jpayne@69: * @see LocalPointer
jpayne@69: * @stable ICU 4.4
jpayne@69: */
jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
jpayne@69:
jpayne@69: U_NAMESPACE_END
jpayne@69:
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * Open a copy of a UNumberFormat.
jpayne@69: * This function performs a deep copy.
jpayne@69: * @param fmt The format to copy
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors.
jpayne@69: * @return A pointer to a UNumberFormat identical to fmt.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE UNumberFormat* U_EXPORT2
jpayne@69: unum_clone(const UNumberFormat *fmt,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format an integer using a UNumberFormat.
jpayne@69: * The integer will be formatted according to the UNumberFormat's locale.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param number The number to format.
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param pos A pointer to a UFieldPosition. On input, position->field
jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate
jpayne@69: * the beginning and ending indices of field number position->field, if such
jpayne@69: * a field exists. This parameter may be NULL, in which case no field
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated.
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_formatDouble
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see UFieldPosition
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_format( const UNumberFormat* fmt,
jpayne@69: int32_t number,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition *pos,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format an int64 using a UNumberFormat.
jpayne@69: * The int64 will be formatted according to the UNumberFormat's locale.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param number The number to format.
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param pos A pointer to a UFieldPosition. On input, position->field
jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate
jpayne@69: * the beginning and ending indices of field number position->field, if such
jpayne@69: * a field exists. This parameter may be NULL, in which case no field
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated.
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatDouble
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see UFieldPosition
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatInt64(const UNumberFormat *fmt,
jpayne@69: int64_t number,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition *pos,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format a double using a UNumberFormat.
jpayne@69: * The double will be formatted according to the UNumberFormat's locale.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param number The number to format.
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param pos A pointer to a UFieldPosition. On input, position->field
jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate
jpayne@69: * the beginning and ending indices of field number position->field, if such
jpayne@69: * a field exists. This parameter may be NULL, in which case no field
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated.
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see UFieldPosition
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatDouble( const UNumberFormat* fmt,
jpayne@69: double number,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition *pos, /* 0 if ignore */
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format a double using a UNumberFormat according to the UNumberFormat's locale,
jpayne@69: * and initialize a UFieldPositionIterator that enumerates the subcomponents of
jpayne@69: * the resulting string.
jpayne@69: *
jpayne@69: * @param format
jpayne@69: * The formatter to use.
jpayne@69: * @param number
jpayne@69: * The number to format.
jpayne@69: * @param result
jpayne@69: * A pointer to a buffer to receive the NULL-terminated formatted
jpayne@69: * number. If the formatted number fits into dest but cannot be
jpayne@69: * NULL-terminated (length == resultLength) then the error code is set
jpayne@69: * to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't
jpayne@69: * fit into result then the error code is set to
jpayne@69: * U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength
jpayne@69: * The maximum size of result.
jpayne@69: * @param fpositer
jpayne@69: * A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
jpayne@69: * (may be NULL if field position information is not needed, but in this
jpayne@69: * case it's preferable to use {@link #unum_formatDouble}). Iteration
jpayne@69: * information already present in the UFieldPositionIterator is deleted,
jpayne@69: * and the iterator is reset to apply to the fields in the formatted
jpayne@69: * string created by this function call. The field values and indexes
jpayne@69: * returned by {@link #ufieldpositer_next} represent fields denoted by
jpayne@69: * the UNumberFormatFields enum. Fields are not returned in a guaranteed
jpayne@69: * order. Fields cannot overlap, but they may nest. For example, 1234
jpayne@69: * could format as "1,234" which might consist of a grouping separator
jpayne@69: * field for ',' and an integer field encompassing the entire string.
jpayne@69: * @param status
jpayne@69: * A pointer to an UErrorCode to receive any errors
jpayne@69: * @return
jpayne@69: * The total buffer size needed; if greater than resultLength, the
jpayne@69: * output was truncated.
jpayne@69: * @see unum_formatDouble
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see UFieldPositionIterator
jpayne@69: * @see UNumberFormatFields
jpayne@69: * @stable ICU 59
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatDoubleForFields(const UNumberFormat* format,
jpayne@69: double number,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPositionIterator* fpositer,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Format a decimal number using a UNumberFormat.
jpayne@69: * The number will be formatted according to the UNumberFormat's locale.
jpayne@69: * The syntax of the input number is a "numeric string"
jpayne@69: * as defined in the Decimal Arithmetic Specification, available at
jpayne@69: * http://speleotrove.com/decimal
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param number The number to format.
jpayne@69: * @param length The length of the input number, or -1 if the input is nul-terminated.
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param pos A pointer to a UFieldPosition. On input, position->field
jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate
jpayne@69: * the beginning and ending indices of field number position->field, if such
jpayne@69: * a field exists. This parameter may be NULL, in which case it is ignored.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated.
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see UFieldPosition
jpayne@69: * @stable ICU 4.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatDecimal( const UNumberFormat* fmt,
jpayne@69: const char * number,
jpayne@69: int32_t length,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition *pos, /* 0 if ignore */
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format a double currency amount using a UNumberFormat.
jpayne@69: * The double will be formatted according to the UNumberFormat's locale.
jpayne@69: * @param fmt the formatter to use
jpayne@69: * @param number the number to format
jpayne@69: * @param currency the 3-letter null-terminated ISO 4217 currency code
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength the maximum number of UChars to write to result
jpayne@69: * @param pos a pointer to a UFieldPosition. On input,
jpayne@69: * position->field is read. On output, position->beginIndex and
jpayne@69: * position->endIndex indicate the beginning and ending indices of
jpayne@69: * field number position->field, if such a field exists. This
jpayne@69: * parameter may be NULL, in which case it is ignored.
jpayne@69: * @param status a pointer to an input-output UErrorCode
jpayne@69: * @return the total buffer size needed; if greater than resultLength,
jpayne@69: * the output was truncated.
jpayne@69: * @see unum_formatDouble
jpayne@69: * @see unum_parseDoubleCurrency
jpayne@69: * @see UFieldPosition
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatDoubleCurrency(const UNumberFormat* fmt,
jpayne@69: double number,
jpayne@69: UChar* currency,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition* pos,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Format a UFormattable into a string.
jpayne@69: * @param fmt the formatter to use
jpayne@69: * @param number the number to format, as a UFormattable
jpayne@69: * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If
jpayne@69: * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength)
jpayne@69: * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number
jpayne@69: * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR.
jpayne@69: * @param resultLength the maximum number of UChars to write to result
jpayne@69: * @param pos a pointer to a UFieldPosition. On input,
jpayne@69: * position->field is read. On output, position->beginIndex and
jpayne@69: * position->endIndex indicate the beginning and ending indices of
jpayne@69: * field number position->field, if such a field exists. This
jpayne@69: * parameter may be NULL, in which case it is ignored.
jpayne@69: * @param status a pointer to an input-output UErrorCode
jpayne@69: * @return the total buffer size needed; if greater than resultLength,
jpayne@69: * the output was truncated. Will return 0 on error.
jpayne@69: * @see unum_parseToUFormattable
jpayne@69: * @stable ICU 52
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_formatUFormattable(const UNumberFormat* fmt,
jpayne@69: const UFormattable *number,
jpayne@69: UChar *result,
jpayne@69: int32_t resultLength,
jpayne@69: UFieldPosition *pos,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a string into an integer using a UNumberFormat.
jpayne@69: * The string will be parsed according to the UNumberFormat's locale.
jpayne@69: * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT
jpayne@69: * and UNUM_DECIMAL_COMPACT_LONG.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param text The text to parse.
jpayne@69: * @param textLength The length of text, or -1 if null-terminated.
jpayne@69: * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
jpayne@69: * to begin parsing. If not NULL, on output the offset at which parsing ended.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The value of the parsed integer
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_formatDouble
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_parse( const UNumberFormat* fmt,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t *parsePos /* 0 = start */,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a string into an int64 using a UNumberFormat.
jpayne@69: * The string will be parsed according to the UNumberFormat's locale.
jpayne@69: * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT
jpayne@69: * and UNUM_DECIMAL_COMPACT_LONG.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param text The text to parse.
jpayne@69: * @param textLength The length of text, or -1 if null-terminated.
jpayne@69: * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
jpayne@69: * to begin parsing. If not NULL, on output the offset at which parsing ended.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The value of the parsed integer
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_formatDouble
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int64_t U_EXPORT2
jpayne@69: unum_parseInt64(const UNumberFormat* fmt,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t *parsePos /* 0 = start */,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a string into a double using a UNumberFormat.
jpayne@69: * The string will be parsed according to the UNumberFormat's locale.
jpayne@69: * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT
jpayne@69: * and UNUM_DECIMAL_COMPACT_LONG.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param text The text to parse.
jpayne@69: * @param textLength The length of text, or -1 if null-terminated.
jpayne@69: * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
jpayne@69: * to begin parsing. If not NULL, on output the offset at which parsing ended.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The value of the parsed double
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_formatDouble
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE double U_EXPORT2
jpayne@69: unum_parseDouble( const UNumberFormat* fmt,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t *parsePos /* 0 = start */,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a number from a string into an unformatted numeric string using a UNumberFormat.
jpayne@69: * The input string will be parsed according to the UNumberFormat's locale.
jpayne@69: * The syntax of the output is a "numeric string"
jpayne@69: * as defined in the Decimal Arithmetic Specification, available at
jpayne@69: * http://speleotrove.com/decimal
jpayne@69: * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT
jpayne@69: * and UNUM_DECIMAL_COMPACT_LONG.
jpayne@69: * @param fmt The formatter to use.
jpayne@69: * @param text The text to parse.
jpayne@69: * @param textLength The length of text, or -1 if null-terminated.
jpayne@69: * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which
jpayne@69: * to begin parsing. If not NULL, on output the offset at which parsing ended.
jpayne@69: * @param outBuf A (char *) buffer to receive the parsed number as a string. The output string
jpayne@69: * will be nul-terminated if there is sufficient space.
jpayne@69: * @param outBufLength The size of the output buffer. May be zero, in which case
jpayne@69: * the outBuf pointer may be NULL, and the function will return the
jpayne@69: * size of the output string.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return the length of the output string, not including any terminating nul.
jpayne@69: * @see unum_parse
jpayne@69: * @see unum_parseInt64
jpayne@69: * @see unum_format
jpayne@69: * @see unum_formatInt64
jpayne@69: * @see unum_formatDouble
jpayne@69: * @stable ICU 4.4
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_parseDecimal(const UNumberFormat* fmt,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t *parsePos /* 0 = start */,
jpayne@69: char *outBuf,
jpayne@69: int32_t outBufLength,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a string into a double and a currency using a UNumberFormat.
jpayne@69: * The string will be parsed according to the UNumberFormat's locale.
jpayne@69: * @param fmt the formatter to use
jpayne@69: * @param text the text to parse
jpayne@69: * @param textLength the length of text, or -1 if null-terminated
jpayne@69: * @param parsePos a pointer to an offset index into text at which to
jpayne@69: * begin parsing. On output, *parsePos will point after the last
jpayne@69: * parsed character. This parameter may be NULL, in which case parsing
jpayne@69: * begins at offset 0.
jpayne@69: * @param currency a pointer to the buffer to receive the parsed null-
jpayne@69: * terminated currency. This buffer must have a capacity of at least
jpayne@69: * 4 UChars.
jpayne@69: * @param status a pointer to an input-output UErrorCode
jpayne@69: * @return the parsed double
jpayne@69: * @see unum_parseDouble
jpayne@69: * @see unum_formatDoubleCurrency
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE double U_EXPORT2
jpayne@69: unum_parseDoubleCurrency(const UNumberFormat* fmt,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t* parsePos, /* 0 = start */
jpayne@69: UChar* currency,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse a UChar string into a UFormattable.
jpayne@69: * Example code:
jpayne@69: * \snippet test/cintltst/cnumtst.c unum_parseToUFormattable
jpayne@69: * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT
jpayne@69: * and UNUM_DECIMAL_COMPACT_LONG.
jpayne@69: * @param fmt the formatter to use
jpayne@69: * @param result the UFormattable to hold the result. If NULL, a new UFormattable will be allocated (which the caller must close with ufmt_close).
jpayne@69: * @param text the text to parse
jpayne@69: * @param textLength the length of text, or -1 if null-terminated
jpayne@69: * @param parsePos a pointer to an offset index into text at which to
jpayne@69: * begin parsing. On output, *parsePos will point after the last
jpayne@69: * parsed character. This parameter may be NULL in which case parsing
jpayne@69: * begins at offset 0.
jpayne@69: * @param status a pointer to an input-output UErrorCode
jpayne@69: * @return the UFormattable. Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable.
jpayne@69: * @see ufmt_getType
jpayne@69: * @see ufmt_close
jpayne@69: * @stable ICU 52
jpayne@69: */
jpayne@69: U_STABLE UFormattable* U_EXPORT2
jpayne@69: unum_parseToUFormattable(const UNumberFormat* fmt,
jpayne@69: UFormattable *result,
jpayne@69: const UChar* text,
jpayne@69: int32_t textLength,
jpayne@69: int32_t* parsePos, /* 0 = start */
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set the pattern used by a UNumberFormat. This can only be used
jpayne@69: * on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR
jpayne@69: * in the status.
jpayne@69: * @param format The formatter to set.
jpayne@69: * @param localized TRUE if the pattern is localized, FALSE otherwise.
jpayne@69: * @param pattern The new pattern
jpayne@69: * @param patternLength The length of pattern, or -1 if null-terminated.
jpayne@69: * @param parseError A pointer to UParseError to receive information
jpayne@69: * about errors occurred during parsing, or NULL if no parse error
jpayne@69: * information is desired.
jpayne@69: * @param status A pointer to an input-output UErrorCode.
jpayne@69: * @see unum_toPattern
jpayne@69: * @see DecimalFormat
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_applyPattern( UNumberFormat *format,
jpayne@69: UBool localized,
jpayne@69: const UChar *pattern,
jpayne@69: int32_t patternLength,
jpayne@69: UParseError *parseError,
jpayne@69: UErrorCode *status
jpayne@69: );
jpayne@69:
jpayne@69: /**
jpayne@69: * Get a locale for which decimal formatting patterns are available.
jpayne@69: * A UNumberFormat in a locale returned by this function will perform the correct
jpayne@69: * formatting and parsing for the locale. The results of this call are not
jpayne@69: * valid for rule-based number formats.
jpayne@69: * @param localeIndex The index of the desired locale.
jpayne@69: * @return A locale for which number formatting patterns are available, or 0 if none.
jpayne@69: * @see unum_countAvailable
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: unum_getAvailable(int32_t localeIndex);
jpayne@69:
jpayne@69: /**
jpayne@69: * Determine how many locales have decimal formatting patterns available. The
jpayne@69: * results of this call are not valid for rule-based number formats.
jpayne@69: * This function is useful for determining the loop ending condition for
jpayne@69: * calls to {@link #unum_getAvailable }.
jpayne@69: * @return The number of locales for which decimal formatting patterns are available.
jpayne@69: * @see unum_getAvailable
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_countAvailable(void);
jpayne@69:
jpayne@69: #if UCONFIG_HAVE_PARSEALLINPUT
jpayne@69: /* The UNumberFormatAttributeValue type cannot be #ifndef U_HIDE_INTERNAL_API, needed for .h variable declaration */
jpayne@69: /**
jpayne@69: * @internal
jpayne@69: */
jpayne@69: typedef enum UNumberFormatAttributeValue {
jpayne@69: #ifndef U_HIDE_INTERNAL_API
jpayne@69: /** @internal */
jpayne@69: UNUM_NO = 0,
jpayne@69: /** @internal */
jpayne@69: UNUM_YES = 1,
jpayne@69: /** @internal */
jpayne@69: UNUM_MAYBE = 2
jpayne@69: #else
jpayne@69: /** @internal */
jpayne@69: UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
jpayne@69: #endif /* U_HIDE_INTERNAL_API */
jpayne@69: } UNumberFormatAttributeValue;
jpayne@69: #endif
jpayne@69:
jpayne@69: /** The possible UNumberFormat numeric attributes @stable ICU 2.0 */
jpayne@69: typedef enum UNumberFormatAttribute {
jpayne@69: /** Parse integers only */
jpayne@69: UNUM_PARSE_INT_ONLY,
jpayne@69: /** Use grouping separator */
jpayne@69: UNUM_GROUPING_USED,
jpayne@69: /** Always show decimal point */
jpayne@69: UNUM_DECIMAL_ALWAYS_SHOWN,
jpayne@69: /** Maximum integer digits */
jpayne@69: UNUM_MAX_INTEGER_DIGITS,
jpayne@69: /** Minimum integer digits */
jpayne@69: UNUM_MIN_INTEGER_DIGITS,
jpayne@69: /** Integer digits */
jpayne@69: UNUM_INTEGER_DIGITS,
jpayne@69: /** Maximum fraction digits */
jpayne@69: UNUM_MAX_FRACTION_DIGITS,
jpayne@69: /** Minimum fraction digits */
jpayne@69: UNUM_MIN_FRACTION_DIGITS,
jpayne@69: /** Fraction digits */
jpayne@69: UNUM_FRACTION_DIGITS,
jpayne@69: /** Multiplier */
jpayne@69: UNUM_MULTIPLIER,
jpayne@69: /** Grouping size */
jpayne@69: UNUM_GROUPING_SIZE,
jpayne@69: /** Rounding Mode */
jpayne@69: UNUM_ROUNDING_MODE,
jpayne@69: /** Rounding increment */
jpayne@69: UNUM_ROUNDING_INCREMENT,
jpayne@69: /** The width to which the output of format()
is padded. */
jpayne@69: UNUM_FORMAT_WIDTH,
jpayne@69: /** The position at which padding will take place. */
jpayne@69: UNUM_PADDING_POSITION,
jpayne@69: /** Secondary grouping size */
jpayne@69: UNUM_SECONDARY_GROUPING_SIZE,
jpayne@69: /** Use significant digits
jpayne@69: * @stable ICU 3.0 */
jpayne@69: UNUM_SIGNIFICANT_DIGITS_USED,
jpayne@69: /** Minimum significant digits
jpayne@69: * @stable ICU 3.0 */
jpayne@69: UNUM_MIN_SIGNIFICANT_DIGITS,
jpayne@69: /** Maximum significant digits
jpayne@69: * @stable ICU 3.0 */
jpayne@69: UNUM_MAX_SIGNIFICANT_DIGITS,
jpayne@69: /** Lenient parse mode used by rule-based formats.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: UNUM_LENIENT_PARSE,
jpayne@69: #if UCONFIG_HAVE_PARSEALLINPUT
jpayne@69: /** Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath), UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic).
jpayne@69: * This is an internal ICU API. Do not use.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: UNUM_PARSE_ALL_INPUT = 20,
jpayne@69: #endif
jpayne@69: /**
jpayne@69: * Scale, which adjusts the position of the
jpayne@69: * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale)
jpayne@69: * before they are formatted. The default value for the scale is 0 ( no adjustment ).
jpayne@69: *
jpayne@69: *
Example: setting the scale to 3, 123 formats as "123,000" jpayne@69: *
Example: setting the scale to -4, 123 formats as "0.0123"
jpayne@69: *
jpayne@69: * This setting is analogous to getMultiplierScale() and setMultiplierScale() in decimfmt.h.
jpayne@69: *
jpayne@69: * @stable ICU 51 */
jpayne@69: UNUM_SCALE = 21,
jpayne@69:
jpayne@69: /**
jpayne@69: * Minimum grouping digits; most commonly set to 2 to print "1000" instead of "1,000".
jpayne@69: * See DecimalFormat::getMinimumGroupingDigits().
jpayne@69: *
jpayne@69: * For better control over grouping strategies, use UNumberFormatter.
jpayne@69: *
jpayne@69: * @stable ICU 64
jpayne@69: */
jpayne@69: UNUM_MINIMUM_GROUPING_DIGITS = 22,
jpayne@69:
jpayne@69: /**
jpayne@69: * if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose,
jpayne@69: * otherwise it is UNUM_CURRENCY_CASH purpose
jpayne@69: * Default: 0 (UNUM_CURRENCY_STANDARD purpose)
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: UNUM_CURRENCY_USAGE = 23,
jpayne@69:
jpayne@69: #ifndef U_HIDE_INTERNAL_API
jpayne@69: /** One below the first bitfield-boolean item.
jpayne@69: * All items after this one are stored in boolean form.
jpayne@69: * @internal */
jpayne@69: UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
jpayne@69: #endif /* U_HIDE_INTERNAL_API */
jpayne@69:
jpayne@69: /** If 1, specifies that if setting the "max integer digits" attribute would truncate a value, set an error status rather than silently truncating.
jpayne@69: * For example, formatting the value 1234 with 4 max int digits would succeed, but formatting 12345 would fail. There is no effect on parsing.
jpayne@69: * Default: 0 (not set)
jpayne@69: * @stable ICU 50
jpayne@69: */
jpayne@69: UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
jpayne@69: /**
jpayne@69: * 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.
jpayne@69: * Has no effect on formatting.
jpayne@69: * Default: 0 (unset)
jpayne@69: * @stable ICU 50
jpayne@69: */
jpayne@69: UNUM_PARSE_NO_EXPONENT = 0x1001,
jpayne@69:
jpayne@69: /**
jpayne@69: * if this attribute is set to 1, specifies that, if the pattern contains a
jpayne@69: * decimal mark the input is required to have one. If this attribute is set to 0,
jpayne@69: * specifies that input does not have to contain a decimal mark.
jpayne@69: * Has no effect on formatting.
jpayne@69: * Default: 0 (unset)
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
jpayne@69:
jpayne@69: /**
jpayne@69: * Parsing: if set to 1, parsing is sensitive to case (lowercase/uppercase).
jpayne@69: *
jpayne@69: * @stable ICU 64
jpayne@69: */
jpayne@69: UNUM_PARSE_CASE_SENSITIVE = 0x1003,
jpayne@69:
jpayne@69: /**
jpayne@69: * Formatting: if set to 1, whether to show the plus sign on non-negative numbers.
jpayne@69: *
jpayne@69: * For better control over sign display, use UNumberFormatter.
jpayne@69: *
jpayne@69: * @stable ICU 64
jpayne@69: */
jpayne@69: UNUM_SIGN_ALWAYS_SHOWN = 0x1004,
jpayne@69:
jpayne@69: #ifndef U_HIDE_INTERNAL_API
jpayne@69: /** Limit of boolean attributes. (value should
jpayne@69: * not depend on U_HIDE conditionals)
jpayne@69: * @internal */
jpayne@69: UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005,
jpayne@69: #endif /* U_HIDE_INTERNAL_API */
jpayne@69:
jpayne@69: } UNumberFormatAttribute;
jpayne@69:
jpayne@69: /**
jpayne@69: * Get a numeric attribute associated with a UNumberFormat.
jpayne@69: * An example of a numeric attribute is the number of integer digits a formatter will produce.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,
jpayne@69: * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,
jpayne@69: * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,
jpayne@69: * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE,
jpayne@69: * UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS.
jpayne@69: * @return The value of attr.
jpayne@69: * @see unum_setAttribute
jpayne@69: * @see unum_getDoubleAttribute
jpayne@69: * @see unum_setDoubleAttribute
jpayne@69: * @see unum_getTextAttribute
jpayne@69: * @see unum_setTextAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_getAttribute(const UNumberFormat* fmt,
jpayne@69: UNumberFormatAttribute attr);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set a numeric attribute associated with a UNumberFormat.
jpayne@69: * An example of a numeric attribute is the number of integer digits a formatter will produce. If the
jpayne@69: * formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand
jpayne@69: * the lenient-parse attribute.
jpayne@69: * @param fmt The formatter to set.
jpayne@69: * @param attr The attribute to set; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,
jpayne@69: * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,
jpayne@69: * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,
jpayne@69: * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE,
jpayne@69: * UNUM_LENIENT_PARSE, UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS.
jpayne@69: * @param newValue The new value of attr.
jpayne@69: * @see unum_getAttribute
jpayne@69: * @see unum_getDoubleAttribute
jpayne@69: * @see unum_setDoubleAttribute
jpayne@69: * @see unum_getTextAttribute
jpayne@69: * @see unum_setTextAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_setAttribute( UNumberFormat* fmt,
jpayne@69: UNumberFormatAttribute attr,
jpayne@69: int32_t newValue);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Get a numeric attribute associated with a UNumberFormat.
jpayne@69: * An example of a numeric attribute is the number of integer digits a formatter will produce.
jpayne@69: * If the formatter does not understand the attribute, -1 is returned.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param attr The attribute to query; e.g. UNUM_ROUNDING_INCREMENT.
jpayne@69: * @return The value of attr.
jpayne@69: * @see unum_getAttribute
jpayne@69: * @see unum_setAttribute
jpayne@69: * @see unum_setDoubleAttribute
jpayne@69: * @see unum_getTextAttribute
jpayne@69: * @see unum_setTextAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE double U_EXPORT2
jpayne@69: unum_getDoubleAttribute(const UNumberFormat* fmt,
jpayne@69: UNumberFormatAttribute attr);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set a numeric attribute associated with a UNumberFormat.
jpayne@69: * An example of a numeric attribute is the number of integer digits a formatter will produce.
jpayne@69: * If the formatter does not understand the attribute, this call is ignored.
jpayne@69: * @param fmt The formatter to set.
jpayne@69: * @param attr The attribute to set; e.g. UNUM_ROUNDING_INCREMENT.
jpayne@69: * @param newValue The new value of attr.
jpayne@69: * @see unum_getAttribute
jpayne@69: * @see unum_setAttribute
jpayne@69: * @see unum_getDoubleAttribute
jpayne@69: * @see unum_getTextAttribute
jpayne@69: * @see unum_setTextAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_setDoubleAttribute( UNumberFormat* fmt,
jpayne@69: UNumberFormatAttribute attr,
jpayne@69: double newValue);
jpayne@69:
jpayne@69: /** The possible UNumberFormat text attributes @stable ICU 2.0*/
jpayne@69: typedef enum UNumberFormatTextAttribute {
jpayne@69: /** Positive prefix */
jpayne@69: UNUM_POSITIVE_PREFIX,
jpayne@69: /** Positive suffix */
jpayne@69: UNUM_POSITIVE_SUFFIX,
jpayne@69: /** Negative prefix */
jpayne@69: UNUM_NEGATIVE_PREFIX,
jpayne@69: /** Negative suffix */
jpayne@69: UNUM_NEGATIVE_SUFFIX,
jpayne@69: /** The character used to pad to the format width. */
jpayne@69: UNUM_PADDING_CHARACTER,
jpayne@69: /** The ISO currency code */
jpayne@69: UNUM_CURRENCY_CODE,
jpayne@69: /**
jpayne@69: * The default rule set, such as "%spellout-numbering-year:", "%spellout-cardinal:",
jpayne@69: * "%spellout-ordinal-masculine-plural:", "%spellout-ordinal-feminine:", or
jpayne@69: * "%spellout-ordinal-neuter:". The available public rulesets can be listed using
jpayne@69: * unum_getTextAttribute with UNUM_PUBLIC_RULESETS. This is only available with
jpayne@69: * rule-based formatters.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: UNUM_DEFAULT_RULESET,
jpayne@69: /**
jpayne@69: * The public rule sets. This is only available with rule-based formatters.
jpayne@69: * This is a read-only attribute. The public rulesets are returned as a
jpayne@69: * single string, with each ruleset name delimited by ';' (semicolon). See the
jpayne@69: * CLDR LDML spec for more information about RBNF rulesets:
jpayne@69: * http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: UNUM_PUBLIC_RULESETS
jpayne@69: } UNumberFormatTextAttribute;
jpayne@69:
jpayne@69: /**
jpayne@69: * Get a text attribute associated with a UNumberFormat.
jpayne@69: * An example of a text attribute is the suffix for positive numbers. If the formatter
jpayne@69: * does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the status.
jpayne@69: * Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RULESETS.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param tag The attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,
jpayne@69: * UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,
jpayne@69: * UNUM_DEFAULT_RULESET, or UNUM_PUBLIC_RULESETS.
jpayne@69: * @param result A pointer to a buffer to receive the attribute.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated.
jpayne@69: * @see unum_setTextAttribute
jpayne@69: * @see unum_getAttribute
jpayne@69: * @see unum_setAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_getTextAttribute( const UNumberFormat* fmt,
jpayne@69: UNumberFormatTextAttribute tag,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set a text attribute associated with a UNumberFormat.
jpayne@69: * An example of a text attribute is the suffix for positive numbers. Rule-based formatters
jpayne@69: * only understand UNUM_DEFAULT_RULESET.
jpayne@69: * @param fmt The formatter to set.
jpayne@69: * @param tag The attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,
jpayne@69: * UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,
jpayne@69: * or UNUM_DEFAULT_RULESET.
jpayne@69: * @param newValue The new value of attr.
jpayne@69: * @param newValueLength The length of newValue, or -1 if null-terminated.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @see unum_getTextAttribute
jpayne@69: * @see unum_getAttribute
jpayne@69: * @see unum_setAttribute
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_setTextAttribute( UNumberFormat* fmt,
jpayne@69: UNumberFormatTextAttribute tag,
jpayne@69: const UChar* newValue,
jpayne@69: int32_t newValueLength,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Extract the pattern from a UNumberFormat. The pattern will follow
jpayne@69: * the DecimalFormat pattern syntax.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param isPatternLocalized TRUE if the pattern should be localized,
jpayne@69: * FALSE otherwise. This is ignored if the formatter is a rule-based
jpayne@69: * formatter.
jpayne@69: * @param result A pointer to a buffer to receive the pattern.
jpayne@69: * @param resultLength The maximum size of result.
jpayne@69: * @param status A pointer to an input-output UErrorCode.
jpayne@69: * @return The total buffer size needed; if greater than resultLength,
jpayne@69: * the output was truncated.
jpayne@69: * @see unum_applyPattern
jpayne@69: * @see DecimalFormat
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_toPattern( const UNumberFormat* fmt,
jpayne@69: UBool isPatternLocalized,
jpayne@69: UChar* result,
jpayne@69: int32_t resultLength,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Constants for specifying a number format symbol.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: typedef enum UNumberFormatSymbol {
jpayne@69: /** The decimal separator */
jpayne@69: UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
jpayne@69: /** The grouping separator */
jpayne@69: UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
jpayne@69: /** The pattern separator */
jpayne@69: UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
jpayne@69: /** The percent sign */
jpayne@69: UNUM_PERCENT_SYMBOL = 3,
jpayne@69: /** Zero*/
jpayne@69: UNUM_ZERO_DIGIT_SYMBOL = 4,
jpayne@69: /** Character representing a digit in the pattern */
jpayne@69: UNUM_DIGIT_SYMBOL = 5,
jpayne@69: /** The minus sign */
jpayne@69: UNUM_MINUS_SIGN_SYMBOL = 6,
jpayne@69: /** The plus sign */
jpayne@69: UNUM_PLUS_SIGN_SYMBOL = 7,
jpayne@69: /** The currency symbol */
jpayne@69: UNUM_CURRENCY_SYMBOL = 8,
jpayne@69: /** The international currency symbol */
jpayne@69: UNUM_INTL_CURRENCY_SYMBOL = 9,
jpayne@69: /** The monetary separator */
jpayne@69: UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
jpayne@69: /** The exponential symbol */
jpayne@69: UNUM_EXPONENTIAL_SYMBOL = 11,
jpayne@69: /** Per mill symbol */
jpayne@69: UNUM_PERMILL_SYMBOL = 12,
jpayne@69: /** Escape padding character */
jpayne@69: UNUM_PAD_ESCAPE_SYMBOL = 13,
jpayne@69: /** Infinity symbol */
jpayne@69: UNUM_INFINITY_SYMBOL = 14,
jpayne@69: /** Nan symbol */
jpayne@69: UNUM_NAN_SYMBOL = 15,
jpayne@69: /** Significant digit symbol
jpayne@69: * @stable ICU 3.0 */
jpayne@69: UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
jpayne@69: /** The monetary grouping separator
jpayne@69: * @stable ICU 3.6
jpayne@69: */
jpayne@69: UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
jpayne@69: /** One
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_ONE_DIGIT_SYMBOL = 18,
jpayne@69: /** Two
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_TWO_DIGIT_SYMBOL = 19,
jpayne@69: /** Three
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_THREE_DIGIT_SYMBOL = 20,
jpayne@69: /** Four
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_FOUR_DIGIT_SYMBOL = 21,
jpayne@69: /** Five
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_FIVE_DIGIT_SYMBOL = 22,
jpayne@69: /** Six
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_SIX_DIGIT_SYMBOL = 23,
jpayne@69: /** Seven
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_SEVEN_DIGIT_SYMBOL = 24,
jpayne@69: /** Eight
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_EIGHT_DIGIT_SYMBOL = 25,
jpayne@69: /** Nine
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: UNUM_NINE_DIGIT_SYMBOL = 26,
jpayne@69:
jpayne@69: /** Multiplication sign
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
jpayne@69:
jpayne@69: #ifndef U_HIDE_DEPRECATED_API
jpayne@69: /**
jpayne@69: * One more than the highest normal UNumberFormatSymbol value.
jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
jpayne@69: */
jpayne@69: UNUM_FORMAT_SYMBOL_COUNT = 28
jpayne@69: #endif /* U_HIDE_DEPRECATED_API */
jpayne@69: } UNumberFormatSymbol;
jpayne@69:
jpayne@69: /**
jpayne@69: * Get a symbol associated with a UNumberFormat.
jpayne@69: * A UNumberFormat uses symbols to represent the special locale-dependent
jpayne@69: * characters in a number, for example the percent sign. This API is not
jpayne@69: * supported for rule-based formatters.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param symbol The UNumberFormatSymbol constant for the symbol to get
jpayne@69: * @param buffer The string buffer that will receive the symbol string;
jpayne@69: * if it is NULL, then only the length of the symbol is returned
jpayne@69: * @param size The size of the string buffer
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The length of the symbol; the buffer is not modified if
jpayne@69: * length>=size
jpayne@69: * @see unum_setSymbol
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: unum_getSymbol(const UNumberFormat *fmt,
jpayne@69: UNumberFormatSymbol symbol,
jpayne@69: UChar *buffer,
jpayne@69: int32_t size,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set a symbol associated with a UNumberFormat.
jpayne@69: * A UNumberFormat uses symbols to represent the special locale-dependent
jpayne@69: * characters in a number, for example the percent sign. This API is not
jpayne@69: * supported for rule-based formatters.
jpayne@69: * @param fmt The formatter to set.
jpayne@69: * @param symbol The UNumberFormatSymbol constant for the symbol to set
jpayne@69: * @param value The string to set the symbol to
jpayne@69: * @param length The length of the string, or -1 for a zero-terminated string
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors.
jpayne@69: * @see unum_getSymbol
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_setSymbol(UNumberFormat *fmt,
jpayne@69: UNumberFormatSymbol symbol,
jpayne@69: const UChar *value,
jpayne@69: int32_t length,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the locale for this number format object.
jpayne@69: * You can choose between valid and actual locale.
jpayne@69: * @param fmt The formatter to get the locale from
jpayne@69: * @param type type of the locale we're looking for (valid or actual)
jpayne@69: * @param status error code for the operation
jpayne@69: * @return the locale name
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: unum_getLocaleByType(const UNumberFormat *fmt,
jpayne@69: ULocDataLocaleType type,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set a particular UDisplayContext value in the formatter, such as
jpayne@69: * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
jpayne@69: * @param fmt The formatter for which to set a UDisplayContext value.
jpayne@69: * @param value The UDisplayContext value to set.
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @stable ICU 53
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
jpayne@69: * such as UDISPCTX_TYPE_CAPITALIZATION.
jpayne@69: * @param fmt The formatter to query.
jpayne@69: * @param type The UDisplayContextType whose value to return
jpayne@69: * @param status A pointer to an UErrorCode to receive any errors
jpayne@69: * @return The UDisplayContextValue for the specified type.
jpayne@69: * @stable ICU 53
jpayne@69: */
jpayne@69: U_STABLE UDisplayContext U_EXPORT2
jpayne@69: unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
jpayne@69:
jpayne@69: #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69:
jpayne@69: #endif