| Index: source/i18n/unicode/unum.h
|
| diff --git a/source/i18n/unicode/unum.h b/source/i18n/unicode/unum.h
|
| index dce77332e96c5b8be56fa81117f13eef5092e37e..c382cc86f9e199cbc4a91b206f902f079966ddb4 100644
|
| --- a/source/i18n/unicode/unum.h
|
| +++ b/source/i18n/unicode/unum.h
|
| @@ -1,6 +1,6 @@
|
| /*
|
| *******************************************************************************
|
| -* Copyright (C) 1997-2013, International Business Machines Corporation and others.
|
| +* Copyright (C) 1997-2014, International Business Machines Corporation and others.
|
| * All Rights Reserved.
|
| * Modification History:
|
| *
|
| @@ -18,9 +18,11 @@
|
|
|
| #include "unicode/localpointer.h"
|
| #include "unicode/uloc.h"
|
| +#include "unicode/ucurr.h"
|
| #include "unicode/umisc.h"
|
| #include "unicode/parseerr.h"
|
| #include "unicode/uformattable.h"
|
| +#include "unicode/udisplaycontext.h"
|
|
|
| /**
|
| * \file
|
| @@ -149,58 +151,78 @@ typedef enum UNumberFormatStyle {
|
| * Currency format with a currency symbol, e.g., "$1.00".
|
| * @stable ICU 2.0
|
| */
|
| - UNUM_CURRENCY,
|
| + UNUM_CURRENCY=2,
|
| /**
|
| * Percent format
|
| * @stable ICU 2.0
|
| */
|
| - UNUM_PERCENT,
|
| + UNUM_PERCENT=3,
|
| /**
|
| * Scientific format
|
| * @stable ICU 2.1
|
| */
|
| - UNUM_SCIENTIFIC,
|
| + UNUM_SCIENTIFIC=4,
|
| /**
|
| - * Spellout rule-based format
|
| + * Spellout rule-based format. The default ruleset can be specified/changed using
|
| + * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets
|
| + * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS.
|
| * @stable ICU 2.0
|
| */
|
| - UNUM_SPELLOUT,
|
| + UNUM_SPELLOUT=5,
|
| /**
|
| - * Ordinal rule-based format
|
| + * Ordinal rule-based format . The default ruleset can be specified/changed using
|
| + * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets
|
| + * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS.
|
| * @stable ICU 3.0
|
| */
|
| - UNUM_ORDINAL,
|
| + UNUM_ORDINAL=6,
|
| /**
|
| * Duration rule-based format
|
| * @stable ICU 3.0
|
| */
|
| - UNUM_DURATION,
|
| + UNUM_DURATION=7,
|
| /**
|
| * Numbering system rule-based format
|
| * @stable ICU 4.2
|
| */
|
| - UNUM_NUMBERING_SYSTEM,
|
| + UNUM_NUMBERING_SYSTEM=8,
|
| /**
|
| * Rule-based format defined by a pattern string.
|
| * @stable ICU 3.0
|
| */
|
| - UNUM_PATTERN_RULEBASED,
|
| + UNUM_PATTERN_RULEBASED=9,
|
| /**
|
| * Currency format with an ISO currency code, e.g., "USD1.00".
|
| * @stable ICU 4.8
|
| */
|
| - UNUM_CURRENCY_ISO,
|
| + UNUM_CURRENCY_ISO=10,
|
| /**
|
| * Currency format with a pluralized currency name,
|
| * e.g., "1.00 US dollar" and "3.00 US dollars".
|
| * @stable ICU 4.8
|
| */
|
| - UNUM_CURRENCY_PLURAL,
|
| + UNUM_CURRENCY_PLURAL=11,
|
| +#ifndef U_HIDE_DRAFT_API
|
| + /**
|
| + * Currency format for accounting, e.g., "($3.00)" for
|
| + * negative currency amount instead of "-$3.00" ({@link #UNUM_CURRENCY}).
|
| + * @draft ICU 53
|
| + */
|
| + UNUM_CURRENCY_ACCOUNTING=12,
|
| + /**
|
| + * Currency format with a currency symbol given CASH usage, e.g.,
|
| + * "NT$3" instead of "NT$3.23".
|
| + * @draft ICU 54
|
| + */
|
| + UNUM_CASH_CURRENCY=13,
|
| +#endif /* U_HIDE_DRAFT_API */
|
| +
|
| /**
|
| * One more than the highest number format style constant.
|
| * @stable ICU 4.8
|
| */
|
| - UNUM_FORMAT_STYLE_COUNT,
|
| + UNUM_FORMAT_STYLE_COUNT=14,
|
| +
|
| /**
|
| * Default format
|
| * @stable ICU 2.0
|
| @@ -252,19 +274,17 @@ typedef enum UNumberFormatPadPosition {
|
| UNUM_PAD_AFTER_SUFFIX
|
| } UNumberFormatPadPosition;
|
|
|
| -#ifndef U_HIDE_DRAFT_API
|
| /**
|
| * Constants for specifying short or long format.
|
| - * @draft ICU 51
|
| + * @stable ICU 51
|
| */
|
| typedef enum UNumberCompactStyle {
|
| - /** @draft ICU 51 */
|
| + /** @stable ICU 51 */
|
| UNUM_SHORT,
|
| - /** @draft ICU 51 */
|
| + /** @stable ICU 51 */
|
| UNUM_LONG
|
| - /** @draft ICU 51 */
|
| + /** @stable ICU 51 */
|
| } UNumberCompactStyle;
|
| -#endif /* U_HIDE_DRAFT_API */
|
|
|
| /**
|
| * Constants for specifying currency spacing
|
| @@ -323,7 +343,9 @@ typedef enum UNumberFormatFields {
|
| * The caller must call {@link #unum_close } when done to release resources
|
| * used by this object.
|
| * @param style The type of number format to open: one of
|
| - * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_SPELLOUT,
|
| + * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC,
|
| + * UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_SPELLOUT,
|
| + * UNUM_ORDINAL, UNUM_DURATION, UNUM_NUMBERING_SYSTEM,
|
| * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT.
|
| * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the
|
| * number format is opened using the given pattern, which must conform
|
| @@ -562,7 +584,6 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt,
|
| UFieldPosition* pos,
|
| UErrorCode* status);
|
|
|
| -#ifndef U_HIDE_DRAFT_API
|
| /**
|
| * Format a UFormattable into a string.
|
| * @param fmt the formatter to use
|
| @@ -581,16 +602,15 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt,
|
| * @return the total buffer size needed; if greater than resultLength,
|
| * the output was truncated. Will return 0 on error.
|
| * @see unum_parseToUFormattable
|
| - * @draft ICU 52
|
| + * @stable ICU 52
|
| */
|
| -U_DRAFT int32_t U_EXPORT2
|
| +U_STABLE int32_t U_EXPORT2
|
| unum_formatUFormattable(const UNumberFormat* fmt,
|
| const UFormattable *number,
|
| UChar *result,
|
| int32_t resultLength,
|
| UFieldPosition *pos,
|
| UErrorCode *status);
|
| -#endif /* U_HIDE_DRAFT_API */
|
|
|
| /**
|
| * Parse a string into an integer using a UNumberFormat.
|
| @@ -726,7 +746,6 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt,
|
| UChar* currency,
|
| UErrorCode* status);
|
|
|
| -#ifndef U_HIDE_DRAFT_API
|
| /**
|
| * Parse a UChar string into a UFormattable.
|
| * Example code:
|
| @@ -743,16 +762,15 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt,
|
| * @return the UFormattable. Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable.
|
| * @see ufmt_getType
|
| * @see ufmt_close
|
| - * @draft ICU 52
|
| + * @stable ICU 52
|
| */
|
| -U_DRAFT UFormattable* U_EXPORT2
|
| +U_STABLE UFormattable* U_EXPORT2
|
| unum_parseToUFormattable(const UNumberFormat* fmt,
|
| UFormattable *result,
|
| const UChar* text,
|
| int32_t textLength,
|
| int32_t* parsePos, /* 0 = start */
|
| UErrorCode* status);
|
| -#endif /* U_HIDE_DRAFT_API */
|
|
|
| /**
|
| * Set the pattern used by a UNumberFormat. This can only be used
|
| @@ -805,16 +823,19 @@ U_STABLE int32_t U_EXPORT2
|
| unum_countAvailable(void);
|
|
|
| #if UCONFIG_HAVE_PARSEALLINPUT
|
| +/* The UNumberFormatAttributeValue type cannot be #ifndef U_HIDE_INTERNAL_API, needed for .h variable declaration */
|
| /**
|
| * @internal
|
| */
|
| typedef enum UNumberFormatAttributeValue {
|
| +#ifndef U_HIDE_INTERNAL_API
|
| /** @internal */
|
| UNUM_NO = 0,
|
| /** @internal */
|
| UNUM_YES = 1,
|
| /** @internal */
|
| UNUM_MAYBE = 2
|
| +#endif /* U_HIDE_INTERNAL_API */
|
| } UNumberFormatAttributeValue;
|
| #endif
|
|
|
| @@ -872,7 +893,6 @@ typedef enum UNumberFormatAttribute {
|
| */
|
| UNUM_PARSE_ALL_INPUT = UNUM_LENIENT_PARSE + 1,
|
| #endif
|
| -#ifndef U_HIDE_DRAFT_API
|
| /**
|
| * Scale, which adjusts the position of the
|
| * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale)
|
| @@ -881,20 +901,30 @@ typedef enum UNumberFormatAttribute {
|
| * <p>Example: setting the scale to 3, 123 formats as "123,000"
|
| * <p>Example: setting the scale to -4, 123 formats as "0.0123"
|
| *
|
| - * @draft ICU 51 */
|
| + * @stable ICU 51 */
|
| UNUM_SCALE = UNUM_LENIENT_PARSE + 2,
|
| -#endif /* U_HIDE_DRAFT_API */
|
|
|
| #ifndef U_HIDE_INTERNAL_API
|
| /** Count of "regular" numeric attributes.
|
| * @internal */
|
| UNUM_NUMERIC_ATTRIBUTE_COUNT = UNUM_LENIENT_PARSE + 3,
|
| +#endif /* U_HIDE_INTERNAL_API */
|
|
|
| +#ifndef U_HIDE_DRAFT_API
|
| + /**
|
| + * if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose,
|
| + * otherwise it is UNUM_CURRENCY_CASH purpose
|
| + * Default: 0 (UNUM_CURRENCY_STANDARD purpose)
|
| + * @draft ICU 54
|
| + */
|
| + UNUM_CURRENCY_USAGE = UNUM_LENIENT_PARSE + 4,
|
| +#endif /* U_HIDE_DRAFT_API */
|
| +
|
| + /* The following cannot be #ifndef U_HIDE_INTERNAL_API, needed in .h file variable declararions */
|
| /** One below the first bitfield-boolean item.
|
| * All items after this one are stored in boolean form.
|
| * @internal */
|
| UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
|
| -#endif /* U_HIDE_INTERNAL_API */
|
|
|
| /** If 1, specifies that if setting the "max integer digits" attribute would truncate a value, set an error status rather than silently truncating.
|
| * For example, formatting the value 1234 with 4 max int digits would succeed, but formatting 12345 would fail. There is no effect on parsing.
|
| @@ -910,11 +940,22 @@ typedef enum UNumberFormatAttribute {
|
| */
|
| UNUM_PARSE_NO_EXPONENT,
|
|
|
| -#ifndef U_HIDE_INTERNAL_API
|
| +#ifndef U_HIDE_DRAFT_API
|
| + /**
|
| + * if this attribute is set to 1, specifies that, if the pattern contains a
|
| + * decimal mark the input is required to have one. If this attribute is set to 0,
|
| + * specifies that input does not have to contain a decimal mark.
|
| + * Has no effect on formatting.
|
| + * Default: 0 (unset)
|
| + * @draft ICU 54
|
| + */
|
| + UNUM_PARSE_DECIMAL_MARK_REQUIRED = UNUM_PARSE_NO_EXPONENT+1,
|
| +#endif /* U_HIDE_DRAFT_API */
|
| +
|
| + /* The following cannot be #ifndef U_HIDE_INTERNAL_API, needed in .h file variable declararions */
|
| /** Limit of boolean attributes.
|
| * @internal */
|
| - UNUM_LIMIT_BOOLEAN_ATTRIBUTE
|
| -#endif /* U_HIDE_INTERNAL_API */
|
| + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = UNUM_PARSE_NO_EXPONENT+2
|
| } UNumberFormatAttribute;
|
|
|
| /**
|
| @@ -1015,14 +1056,20 @@ typedef enum UNumberFormatTextAttribute {
|
| /** The ISO currency code */
|
| UNUM_CURRENCY_CODE,
|
| /**
|
| - * The default rule set. This is only available with rule-based formatters.
|
| + * The default rule set, such as "%spellout-numbering-year:", "%spellout-cardinal:",
|
| + * "%spellout-ordinal-masculine-plural:", "%spellout-ordinal-feminine:", or
|
| + * "%spellout-ordinal-neuter:". The available public rulesets can be listed using
|
| + * unum_getTextAttribute with UNUM_PUBLIC_RULESETS. This is only available with
|
| + * rule-based formatters.
|
| * @stable ICU 3.0
|
| */
|
| UNUM_DEFAULT_RULESET,
|
| /**
|
| * The public rule sets. This is only available with rule-based formatters.
|
| * This is a read-only attribute. The public rulesets are returned as a
|
| - * single string, with each ruleset name delimited by ';' (semicolon).
|
| + * single string, with each ruleset name delimited by ';' (semicolon). See the
|
| + * CLDR LDML spec for more information about RBNF rulesets:
|
| + * http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting
|
| * @stable ICU 3.0
|
| */
|
| UNUM_PUBLIC_RULESETS
|
| @@ -1180,8 +1227,16 @@ typedef enum UNumberFormatSymbol {
|
| * @stable ICU 4.6
|
| */
|
| UNUM_NINE_DIGIT_SYMBOL = 26,
|
| +
|
| +#ifndef U_HIDE_DRAFT_API
|
| + /** Multiplication sign
|
| + * @draft ICU 54
|
| + */
|
| + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
|
| +#endif /* U_HIDE_DRAFT_API */
|
| +
|
| /** count symbol constants */
|
| - UNUM_FORMAT_SYMBOL_COUNT = 27
|
| + UNUM_FORMAT_SYMBOL_COUNT = 28
|
| } UNumberFormatSymbol;
|
|
|
| /**
|
| @@ -1242,6 +1297,32 @@ unum_getLocaleByType(const UNumberFormat *fmt,
|
| ULocDataLocaleType type,
|
| UErrorCode* status);
|
|
|
| +#ifndef U_HIDE_DRAFT_API
|
| +/**
|
| + * Set a particular UDisplayContext value in the formatter, such as
|
| + * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
|
| + * @param fmt The formatter for which to set a UDisplayContext value.
|
| + * @param value The UDisplayContext value to set.
|
| + * @param status A pointer to an UErrorCode to receive any errors
|
| + * @draft ICU 53
|
| + */
|
| +U_DRAFT void U_EXPORT2
|
| +unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
|
| +
|
| +/**
|
| + * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
|
| + * such as UDISPCTX_TYPE_CAPITALIZATION.
|
| + * @param fmt The formatter to query.
|
| + * @param type The UDisplayContextType whose value to return
|
| + * @param status A pointer to an UErrorCode to receive any errors
|
| + * @return The UDisplayContextValue for the specified type.
|
| + * @draft ICU 53
|
| + */
|
| +U_DRAFT UDisplayContext U_EXPORT2
|
| +unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
|
| +
|
| +#endif /* U_HIDE_DRAFT_API */
|
| +
|
| #endif /* #if !UCONFIG_NO_FORMATTING */
|
|
|
| #endif
|
|
|