OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 1997-2013, International Business Machines Corporation and other
s. | 3 * Copyright (C) 1997-2014, International Business Machines Corporation and other
s. |
4 * All Rights Reserved. | 4 * All Rights Reserved. |
5 * Modification History: | 5 * Modification History: |
6 * | 6 * |
7 * Date Name Description | 7 * Date Name Description |
8 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixe
s | 8 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixe
s |
9 ******************************************************************************* | 9 ******************************************************************************* |
10 */ | 10 */ |
11 | 11 |
12 #ifndef _UNUM | 12 #ifndef _UNUM |
13 #define _UNUM | 13 #define _UNUM |
14 | 14 |
15 #include "unicode/utypes.h" | 15 #include "unicode/utypes.h" |
16 | 16 |
17 #if !UCONFIG_NO_FORMATTING | 17 #if !UCONFIG_NO_FORMATTING |
18 | 18 |
19 #include "unicode/localpointer.h" | 19 #include "unicode/localpointer.h" |
20 #include "unicode/uloc.h" | 20 #include "unicode/uloc.h" |
| 21 #include "unicode/ucurr.h" |
21 #include "unicode/umisc.h" | 22 #include "unicode/umisc.h" |
22 #include "unicode/parseerr.h" | 23 #include "unicode/parseerr.h" |
23 #include "unicode/uformattable.h" | 24 #include "unicode/uformattable.h" |
| 25 #include "unicode/udisplaycontext.h" |
24 | 26 |
25 /** | 27 /** |
26 * \file | 28 * \file |
27 * \brief C API: NumberFormat | 29 * \brief C API: NumberFormat |
28 * | 30 * |
29 * <h2> Number Format C API </h2> | 31 * <h2> Number Format C API </h2> |
30 * | 32 * |
31 * Number Format C API Provides functions for | 33 * Number Format C API Provides functions for |
32 * formatting and parsing a number. Also provides methods for | 34 * formatting and parsing a number. Also provides methods for |
33 * determining which locales have number formats, and what their names | 35 * determining which locales have number formats, and what their names |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 UNUM_PATTERN_DECIMAL=0, | 144 UNUM_PATTERN_DECIMAL=0, |
143 /** | 145 /** |
144 * Decimal format ("normal" style). | 146 * Decimal format ("normal" style). |
145 * @stable ICU 2.0 | 147 * @stable ICU 2.0 |
146 */ | 148 */ |
147 UNUM_DECIMAL=1, | 149 UNUM_DECIMAL=1, |
148 /** | 150 /** |
149 * Currency format with a currency symbol, e.g., "$1.00". | 151 * Currency format with a currency symbol, e.g., "$1.00". |
150 * @stable ICU 2.0 | 152 * @stable ICU 2.0 |
151 */ | 153 */ |
152 UNUM_CURRENCY, | 154 UNUM_CURRENCY=2, |
153 /** | 155 /** |
154 * Percent format | 156 * Percent format |
155 * @stable ICU 2.0 | 157 * @stable ICU 2.0 |
156 */ | 158 */ |
157 UNUM_PERCENT, | 159 UNUM_PERCENT=3, |
158 /** | 160 /** |
159 * Scientific format | 161 * Scientific format |
160 * @stable ICU 2.1 | 162 * @stable ICU 2.1 |
161 */ | 163 */ |
162 UNUM_SCIENTIFIC, | 164 UNUM_SCIENTIFIC=4, |
163 /** | 165 /** |
164 * Spellout rule-based format | 166 * Spellout rule-based format. The default ruleset can be specified/changed
using |
| 167 * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rul
esets |
| 168 * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. |
165 * @stable ICU 2.0 | 169 * @stable ICU 2.0 |
166 */ | 170 */ |
167 UNUM_SPELLOUT, | 171 UNUM_SPELLOUT=5, |
168 /** | 172 /** |
169 * Ordinal rule-based format | 173 * Ordinal rule-based format . The default ruleset can be specified/changed
using |
| 174 * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rul
esets |
| 175 * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. |
170 * @stable ICU 3.0 | 176 * @stable ICU 3.0 |
171 */ | 177 */ |
172 UNUM_ORDINAL, | 178 UNUM_ORDINAL=6, |
173 /** | 179 /** |
174 * Duration rule-based format | 180 * Duration rule-based format |
175 * @stable ICU 3.0 | 181 * @stable ICU 3.0 |
176 */ | 182 */ |
177 UNUM_DURATION, | 183 UNUM_DURATION=7, |
178 /** | 184 /** |
179 * Numbering system rule-based format | 185 * Numbering system rule-based format |
180 * @stable ICU 4.2 | 186 * @stable ICU 4.2 |
181 */ | 187 */ |
182 UNUM_NUMBERING_SYSTEM, | 188 UNUM_NUMBERING_SYSTEM=8, |
183 /** | 189 /** |
184 * Rule-based format defined by a pattern string. | 190 * Rule-based format defined by a pattern string. |
185 * @stable ICU 3.0 | 191 * @stable ICU 3.0 |
186 */ | 192 */ |
187 UNUM_PATTERN_RULEBASED, | 193 UNUM_PATTERN_RULEBASED=9, |
188 /** | 194 /** |
189 * Currency format with an ISO currency code, e.g., "USD1.00". | 195 * Currency format with an ISO currency code, e.g., "USD1.00". |
190 * @stable ICU 4.8 | 196 * @stable ICU 4.8 |
191 */ | 197 */ |
192 UNUM_CURRENCY_ISO, | 198 UNUM_CURRENCY_ISO=10, |
193 /** | 199 /** |
194 * Currency format with a pluralized currency name, | 200 * Currency format with a pluralized currency name, |
195 * e.g., "1.00 US dollar" and "3.00 US dollars". | 201 * e.g., "1.00 US dollar" and "3.00 US dollars". |
196 * @stable ICU 4.8 | 202 * @stable ICU 4.8 |
197 */ | 203 */ |
198 UNUM_CURRENCY_PLURAL, | 204 UNUM_CURRENCY_PLURAL=11, |
| 205 #ifndef U_HIDE_DRAFT_API |
| 206 /** |
| 207 * Currency format for accounting, e.g., "($3.00)" for |
| 208 * negative currency amount instead of "-$3.00" ({@link #UNUM_CURRENCY}). |
| 209 * @draft ICU 53 |
| 210 */ |
| 211 UNUM_CURRENCY_ACCOUNTING=12, |
| 212 /** |
| 213 * Currency format with a currency symbol given CASH usage, e.g., |
| 214 * "NT$3" instead of "NT$3.23". |
| 215 * @draft ICU 54 |
| 216 */ |
| 217 UNUM_CASH_CURRENCY=13, |
| 218 #endif /* U_HIDE_DRAFT_API */ |
| 219 |
199 /** | 220 /** |
200 * One more than the highest number format style constant. | 221 * One more than the highest number format style constant. |
201 * @stable ICU 4.8 | 222 * @stable ICU 4.8 |
202 */ | 223 */ |
203 UNUM_FORMAT_STYLE_COUNT, | 224 UNUM_FORMAT_STYLE_COUNT=14, |
| 225 |
204 /** | 226 /** |
205 * Default format | 227 * Default format |
206 * @stable ICU 2.0 | 228 * @stable ICU 2.0 |
207 */ | 229 */ |
208 UNUM_DEFAULT = UNUM_DECIMAL, | 230 UNUM_DEFAULT = UNUM_DECIMAL, |
209 /** | 231 /** |
210 * Alias for UNUM_PATTERN_DECIMAL | 232 * Alias for UNUM_PATTERN_DECIMAL |
211 * @stable ICU 3.0 | 233 * @stable ICU 3.0 |
212 */ | 234 */ |
213 UNUM_IGNORE = UNUM_PATTERN_DECIMAL | 235 UNUM_IGNORE = UNUM_PATTERN_DECIMAL |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 /** The possible number format pad positions. | 267 /** The possible number format pad positions. |
246 * @stable ICU 2.0 | 268 * @stable ICU 2.0 |
247 */ | 269 */ |
248 typedef enum UNumberFormatPadPosition { | 270 typedef enum UNumberFormatPadPosition { |
249 UNUM_PAD_BEFORE_PREFIX, | 271 UNUM_PAD_BEFORE_PREFIX, |
250 UNUM_PAD_AFTER_PREFIX, | 272 UNUM_PAD_AFTER_PREFIX, |
251 UNUM_PAD_BEFORE_SUFFIX, | 273 UNUM_PAD_BEFORE_SUFFIX, |
252 UNUM_PAD_AFTER_SUFFIX | 274 UNUM_PAD_AFTER_SUFFIX |
253 } UNumberFormatPadPosition; | 275 } UNumberFormatPadPosition; |
254 | 276 |
255 #ifndef U_HIDE_DRAFT_API | |
256 /** | 277 /** |
257 * Constants for specifying short or long format. | 278 * Constants for specifying short or long format. |
258 * @draft ICU 51 | 279 * @stable ICU 51 |
259 */ | 280 */ |
260 typedef enum UNumberCompactStyle { | 281 typedef enum UNumberCompactStyle { |
261 /** @draft ICU 51 */ | 282 /** @stable ICU 51 */ |
262 UNUM_SHORT, | 283 UNUM_SHORT, |
263 /** @draft ICU 51 */ | 284 /** @stable ICU 51 */ |
264 UNUM_LONG | 285 UNUM_LONG |
265 /** @draft ICU 51 */ | 286 /** @stable ICU 51 */ |
266 } UNumberCompactStyle; | 287 } UNumberCompactStyle; |
267 #endif /* U_HIDE_DRAFT_API */ | |
268 | 288 |
269 /** | 289 /** |
270 * Constants for specifying currency spacing | 290 * Constants for specifying currency spacing |
271 * @stable ICU 4.8 | 291 * @stable ICU 4.8 |
272 */ | 292 */ |
273 enum UCurrencySpacing { | 293 enum UCurrencySpacing { |
274 /** @stable ICU 4.8 */ | 294 /** @stable ICU 4.8 */ |
275 UNUM_CURRENCY_MATCH, | 295 UNUM_CURRENCY_MATCH, |
276 /** @stable ICU 4.8 */ | 296 /** @stable ICU 4.8 */ |
277 UNUM_CURRENCY_SURROUNDING_MATCH, | 297 UNUM_CURRENCY_SURROUNDING_MATCH, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } UNumberFormatFields; | 336 } UNumberFormatFields; |
317 | 337 |
318 | 338 |
319 /** | 339 /** |
320 * Create and return a new UNumberFormat for formatting and parsing | 340 * Create and return a new UNumberFormat for formatting and parsing |
321 * numbers. A UNumberFormat may be used to format numbers by calling | 341 * numbers. A UNumberFormat may be used to format numbers by calling |
322 * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }. | 342 * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }. |
323 * The caller must call {@link #unum_close } when done to release resources | 343 * The caller must call {@link #unum_close } when done to release resources |
324 * used by this object. | 344 * used by this object. |
325 * @param style The type of number format to open: one of | 345 * @param style The type of number format to open: one of |
326 * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_SPELLOUT, | 346 * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, |
| 347 * UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_SPELLOUT, |
| 348 * UNUM_ORDINAL, UNUM_DURATION, UNUM_NUMBERING_SYSTEM, |
327 * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT. | 349 * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT. |
328 * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the | 350 * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the |
329 * number format is opened using the given pattern, which must conform | 351 * number format is opened using the given pattern, which must conform |
330 * to the syntax described in DecimalFormat or RuleBasedNumberFormat, | 352 * to the syntax described in DecimalFormat or RuleBasedNumberFormat, |
331 * respectively. | 353 * respectively. |
332 * @param pattern A pattern specifying the format to use. | 354 * @param pattern A pattern specifying the format to use. |
333 * This parameter is ignored unless the style is | 355 * This parameter is ignored unless the style is |
334 * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED. | 356 * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED. |
335 * @param patternLength The number of characters in the pattern, or -1 | 357 * @param patternLength The number of characters in the pattern, or -1 |
336 * if null-terminated. This parameter is ignored unless the style is | 358 * if null-terminated. This parameter is ignored unless the style is |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 */ | 577 */ |
556 U_STABLE int32_t U_EXPORT2 | 578 U_STABLE int32_t U_EXPORT2 |
557 unum_formatDoubleCurrency(const UNumberFormat* fmt, | 579 unum_formatDoubleCurrency(const UNumberFormat* fmt, |
558 double number, | 580 double number, |
559 UChar* currency, | 581 UChar* currency, |
560 UChar* result, | 582 UChar* result, |
561 int32_t resultLength, | 583 int32_t resultLength, |
562 UFieldPosition* pos, | 584 UFieldPosition* pos, |
563 UErrorCode* status); | 585 UErrorCode* status); |
564 | 586 |
565 #ifndef U_HIDE_DRAFT_API | |
566 /** | 587 /** |
567 * Format a UFormattable into a string. | 588 * Format a UFormattable into a string. |
568 * @param fmt the formatter to use | 589 * @param fmt the formatter to use |
569 * @param number the number to format, as a UFormattable | 590 * @param number the number to format, as a UFormattable |
570 * @param result A pointer to a buffer to receive the NULL-terminated formatted
number. If | 591 * @param result A pointer to a buffer to receive the NULL-terminated formatted
number. If |
571 * the formatted number fits into dest but cannot be NULL-terminated (length ==
resultLength) | 592 * the formatted number fits into dest but cannot be NULL-terminated (length ==
resultLength) |
572 * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatt
ed number | 593 * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatt
ed number |
573 * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR
. | 594 * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR
. |
574 * @param resultLength the maximum number of UChars to write to result | 595 * @param resultLength the maximum number of UChars to write to result |
575 * @param pos a pointer to a UFieldPosition. On input, | 596 * @param pos a pointer to a UFieldPosition. On input, |
576 * position->field is read. On output, position->beginIndex and | 597 * position->field is read. On output, position->beginIndex and |
577 * position->endIndex indicate the beginning and ending indices of | 598 * position->endIndex indicate the beginning and ending indices of |
578 * field number position->field, if such a field exists. This | 599 * field number position->field, if such a field exists. This |
579 * parameter may be NULL, in which case it is ignored. | 600 * parameter may be NULL, in which case it is ignored. |
580 * @param status a pointer to an input-output UErrorCode | 601 * @param status a pointer to an input-output UErrorCode |
581 * @return the total buffer size needed; if greater than resultLength, | 602 * @return the total buffer size needed; if greater than resultLength, |
582 * the output was truncated. Will return 0 on error. | 603 * the output was truncated. Will return 0 on error. |
583 * @see unum_parseToUFormattable | 604 * @see unum_parseToUFormattable |
584 * @draft ICU 52 | 605 * @stable ICU 52 |
585 */ | 606 */ |
586 U_DRAFT int32_t U_EXPORT2 | 607 U_STABLE int32_t U_EXPORT2 |
587 unum_formatUFormattable(const UNumberFormat* fmt, | 608 unum_formatUFormattable(const UNumberFormat* fmt, |
588 const UFormattable *number, | 609 const UFormattable *number, |
589 UChar *result, | 610 UChar *result, |
590 int32_t resultLength, | 611 int32_t resultLength, |
591 UFieldPosition *pos, | 612 UFieldPosition *pos, |
592 UErrorCode *status); | 613 UErrorCode *status); |
593 #endif /* U_HIDE_DRAFT_API */ | |
594 | 614 |
595 /** | 615 /** |
596 * Parse a string into an integer using a UNumberFormat. | 616 * Parse a string into an integer using a UNumberFormat. |
597 * The string will be parsed according to the UNumberFormat's locale. | 617 * The string will be parsed according to the UNumberFormat's locale. |
598 * @param fmt The formatter to use. | 618 * @param fmt The formatter to use. |
599 * @param text The text to parse. | 619 * @param text The text to parse. |
600 * @param textLength The length of text, or -1 if null-terminated. | 620 * @param textLength The length of text, or -1 if null-terminated. |
601 * @param parsePos If not NULL, on input a pointer to an integer specifying the o
ffset at which | 621 * @param parsePos If not NULL, on input a pointer to an integer specifying the o
ffset at which |
602 * to begin parsing. If not NULL, on output the offset at which parsing ended. | 622 * to begin parsing. If not NULL, on output the offset at which parsing ended. |
603 * @param status A pointer to an UErrorCode to receive any errors | 623 * @param status A pointer to an UErrorCode to receive any errors |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 * @stable ICU 3.0 | 739 * @stable ICU 3.0 |
720 */ | 740 */ |
721 U_STABLE double U_EXPORT2 | 741 U_STABLE double U_EXPORT2 |
722 unum_parseDoubleCurrency(const UNumberFormat* fmt, | 742 unum_parseDoubleCurrency(const UNumberFormat* fmt, |
723 const UChar* text, | 743 const UChar* text, |
724 int32_t textLength, | 744 int32_t textLength, |
725 int32_t* parsePos, /* 0 = start */ | 745 int32_t* parsePos, /* 0 = start */ |
726 UChar* currency, | 746 UChar* currency, |
727 UErrorCode* status); | 747 UErrorCode* status); |
728 | 748 |
729 #ifndef U_HIDE_DRAFT_API | |
730 /** | 749 /** |
731 * Parse a UChar string into a UFormattable. | 750 * Parse a UChar string into a UFormattable. |
732 * Example code: | 751 * Example code: |
733 * \snippet test/cintltst/cnumtst.c unum_parseToUFormattable | 752 * \snippet test/cintltst/cnumtst.c unum_parseToUFormattable |
734 * @param fmt the formatter to use | 753 * @param fmt the formatter to use |
735 * @param result the UFormattable to hold the result. If NULL, a new UFormattabl
e will be allocated (which the caller must close with ufmt_close). | 754 * @param result the UFormattable to hold the result. If NULL, a new UFormattabl
e will be allocated (which the caller must close with ufmt_close). |
736 * @param text the text to parse | 755 * @param text the text to parse |
737 * @param textLength the length of text, or -1 if null-terminated | 756 * @param textLength the length of text, or -1 if null-terminated |
738 * @param parsePos a pointer to an offset index into text at which to | 757 * @param parsePos a pointer to an offset index into text at which to |
739 * begin parsing. On output, *parsePos will point after the last | 758 * begin parsing. On output, *parsePos will point after the last |
740 * parsed character. This parameter may be NULL in which case parsing | 759 * parsed character. This parameter may be NULL in which case parsing |
741 * begins at offset 0. | 760 * begins at offset 0. |
742 * @param status a pointer to an input-output UErrorCode | 761 * @param status a pointer to an input-output UErrorCode |
743 * @return the UFormattable. Will be ==result unless NULL was passed in for res
ult, in which case it will be the newly opened UFormattable. | 762 * @return the UFormattable. Will be ==result unless NULL was passed in for res
ult, in which case it will be the newly opened UFormattable. |
744 * @see ufmt_getType | 763 * @see ufmt_getType |
745 * @see ufmt_close | 764 * @see ufmt_close |
746 * @draft ICU 52 | 765 * @stable ICU 52 |
747 */ | 766 */ |
748 U_DRAFT UFormattable* U_EXPORT2 | 767 U_STABLE UFormattable* U_EXPORT2 |
749 unum_parseToUFormattable(const UNumberFormat* fmt, | 768 unum_parseToUFormattable(const UNumberFormat* fmt, |
750 UFormattable *result, | 769 UFormattable *result, |
751 const UChar* text, | 770 const UChar* text, |
752 int32_t textLength, | 771 int32_t textLength, |
753 int32_t* parsePos, /* 0 = start */ | 772 int32_t* parsePos, /* 0 = start */ |
754 UErrorCode* status); | 773 UErrorCode* status); |
755 #endif /* U_HIDE_DRAFT_API */ | |
756 | 774 |
757 /** | 775 /** |
758 * Set the pattern used by a UNumberFormat. This can only be used | 776 * Set the pattern used by a UNumberFormat. This can only be used |
759 * on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR | 777 * on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR |
760 * in the status. | 778 * in the status. |
761 * @param format The formatter to set. | 779 * @param format The formatter to set. |
762 * @param localized TRUE if the pattern is localized, FALSE otherwise. | 780 * @param localized TRUE if the pattern is localized, FALSE otherwise. |
763 * @param pattern The new pattern | 781 * @param pattern The new pattern |
764 * @param patternLength The length of pattern, or -1 if null-terminated. | 782 * @param patternLength The length of pattern, or -1 if null-terminated. |
765 * @param parseError A pointer to UParseError to recieve information | 783 * @param parseError A pointer to UParseError to recieve information |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 * This function is useful for determining the loop ending condition for | 816 * This function is useful for determining the loop ending condition for |
799 * calls to {@link #unum_getAvailable }. | 817 * calls to {@link #unum_getAvailable }. |
800 * @return The number of locales for which decimal formatting patterns are availa
ble. | 818 * @return The number of locales for which decimal formatting patterns are availa
ble. |
801 * @see unum_getAvailable | 819 * @see unum_getAvailable |
802 * @stable ICU 2.0 | 820 * @stable ICU 2.0 |
803 */ | 821 */ |
804 U_STABLE int32_t U_EXPORT2 | 822 U_STABLE int32_t U_EXPORT2 |
805 unum_countAvailable(void); | 823 unum_countAvailable(void); |
806 | 824 |
807 #if UCONFIG_HAVE_PARSEALLINPUT | 825 #if UCONFIG_HAVE_PARSEALLINPUT |
| 826 /* The UNumberFormatAttributeValue type cannot be #ifndef U_HIDE_INTERNAL_API, n
eeded for .h variable declaration */ |
808 /** | 827 /** |
809 * @internal | 828 * @internal |
810 */ | 829 */ |
811 typedef enum UNumberFormatAttributeValue { | 830 typedef enum UNumberFormatAttributeValue { |
| 831 #ifndef U_HIDE_INTERNAL_API |
812 /** @internal */ | 832 /** @internal */ |
813 UNUM_NO = 0, | 833 UNUM_NO = 0, |
814 /** @internal */ | 834 /** @internal */ |
815 UNUM_YES = 1, | 835 UNUM_YES = 1, |
816 /** @internal */ | 836 /** @internal */ |
817 UNUM_MAYBE = 2 | 837 UNUM_MAYBE = 2 |
| 838 #endif /* U_HIDE_INTERNAL_API */ |
818 } UNumberFormatAttributeValue; | 839 } UNumberFormatAttributeValue; |
819 #endif | 840 #endif |
820 | 841 |
821 /** The possible UNumberFormat numeric attributes @stable ICU 2.0 */ | 842 /** The possible UNumberFormat numeric attributes @stable ICU 2.0 */ |
822 typedef enum UNumberFormatAttribute { | 843 typedef enum UNumberFormatAttribute { |
823 /** Parse integers only */ | 844 /** Parse integers only */ |
824 UNUM_PARSE_INT_ONLY, | 845 UNUM_PARSE_INT_ONLY, |
825 /** Use grouping separator */ | 846 /** Use grouping separator */ |
826 UNUM_GROUPING_USED, | 847 UNUM_GROUPING_USED, |
827 /** Always show decimal point */ | 848 /** Always show decimal point */ |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 * @stable ICU 3.0 | 886 * @stable ICU 3.0 |
866 */ | 887 */ |
867 UNUM_LENIENT_PARSE, | 888 UNUM_LENIENT_PARSE, |
868 #if UCONFIG_HAVE_PARSEALLINPUT | 889 #if UCONFIG_HAVE_PARSEALLINPUT |
869 /** Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath),
UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic). | 890 /** Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath),
UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic). |
870 * This is an internal ICU API. Do not use. | 891 * This is an internal ICU API. Do not use. |
871 * @internal | 892 * @internal |
872 */ | 893 */ |
873 UNUM_PARSE_ALL_INPUT = UNUM_LENIENT_PARSE + 1, | 894 UNUM_PARSE_ALL_INPUT = UNUM_LENIENT_PARSE + 1, |
874 #endif | 895 #endif |
875 #ifndef U_HIDE_DRAFT_API | |
876 /** | 896 /** |
877 * Scale, which adjusts the position of the | 897 * Scale, which adjusts the position of the |
878 * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale) | 898 * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale) |
879 * before they are formatted. The default value for the scale is 0 ( no adju
stment ). | 899 * before they are formatted. The default value for the scale is 0 ( no adju
stment ). |
880 * | 900 * |
881 * <p>Example: setting the scale to 3, 123 formats as "123,000" | 901 * <p>Example: setting the scale to 3, 123 formats as "123,000" |
882 * <p>Example: setting the scale to -4, 123 formats as "0.0123" | 902 * <p>Example: setting the scale to -4, 123 formats as "0.0123" |
883 * | 903 * |
884 * @draft ICU 51 */ | 904 * @stable ICU 51 */ |
885 UNUM_SCALE = UNUM_LENIENT_PARSE + 2, | 905 UNUM_SCALE = UNUM_LENIENT_PARSE + 2, |
886 #endif /* U_HIDE_DRAFT_API */ | |
887 | 906 |
888 #ifndef U_HIDE_INTERNAL_API | 907 #ifndef U_HIDE_INTERNAL_API |
889 /** Count of "regular" numeric attributes. | 908 /** Count of "regular" numeric attributes. |
890 * @internal */ | 909 * @internal */ |
891 UNUM_NUMERIC_ATTRIBUTE_COUNT = UNUM_LENIENT_PARSE + 3, | 910 UNUM_NUMERIC_ATTRIBUTE_COUNT = UNUM_LENIENT_PARSE + 3, |
| 911 #endif /* U_HIDE_INTERNAL_API */ |
892 | 912 |
| 913 #ifndef U_HIDE_DRAFT_API |
| 914 /** |
| 915 * if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose, |
| 916 * otherwise it is UNUM_CURRENCY_CASH purpose |
| 917 * Default: 0 (UNUM_CURRENCY_STANDARD purpose) |
| 918 * @draft ICU 54 |
| 919 */ |
| 920 UNUM_CURRENCY_USAGE = UNUM_LENIENT_PARSE + 4, |
| 921 #endif /* U_HIDE_DRAFT_API */ |
| 922 |
| 923 /* The following cannot be #ifndef U_HIDE_INTERNAL_API, needed in .h file vari
able declararions */ |
893 /** One below the first bitfield-boolean item. | 924 /** One below the first bitfield-boolean item. |
894 * All items after this one are stored in boolean form. | 925 * All items after this one are stored in boolean form. |
895 * @internal */ | 926 * @internal */ |
896 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF, | 927 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF, |
897 #endif /* U_HIDE_INTERNAL_API */ | |
898 | 928 |
899 /** If 1, specifies that if setting the "max integer digits" attribute would t
runcate a value, set an error status rather than silently truncating. | 929 /** If 1, specifies that if setting the "max integer digits" attribute would t
runcate a value, set an error status rather than silently truncating. |
900 * For example, formatting the value 1234 with 4 max int digits would succeed
, but formatting 12345 would fail. There is no effect on parsing. | 930 * For example, formatting the value 1234 with 4 max int digits would succeed
, but formatting 12345 would fail. There is no effect on parsing. |
901 * Default: 0 (not set) | 931 * Default: 0 (not set) |
902 * @stable ICU 50 | 932 * @stable ICU 50 |
903 */ | 933 */ |
904 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000, | 934 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000, |
905 /** | 935 /** |
906 * if this attribute is set to 1, specifies that, if the pattern doesn't conta
in an exponent, the exponent will not be parsed. If the pattern does contain an
exponent, this attribute has no effect. | 936 * if this attribute is set to 1, specifies that, if the pattern doesn't conta
in an exponent, the exponent will not be parsed. If the pattern does contain an
exponent, this attribute has no effect. |
907 * Has no effect on formatting. | 937 * Has no effect on formatting. |
908 * Default: 0 (unset) | 938 * Default: 0 (unset) |
909 * @stable ICU 50 | 939 * @stable ICU 50 |
910 */ | 940 */ |
911 UNUM_PARSE_NO_EXPONENT, | 941 UNUM_PARSE_NO_EXPONENT, |
912 | 942 |
913 #ifndef U_HIDE_INTERNAL_API | 943 #ifndef U_HIDE_DRAFT_API |
| 944 /** |
| 945 * if this attribute is set to 1, specifies that, if the pattern contains a |
| 946 * decimal mark the input is required to have one. If this attribute is set to
0, |
| 947 * specifies that input does not have to contain a decimal mark. |
| 948 * Has no effect on formatting. |
| 949 * Default: 0 (unset) |
| 950 * @draft ICU 54 |
| 951 */ |
| 952 UNUM_PARSE_DECIMAL_MARK_REQUIRED = UNUM_PARSE_NO_EXPONENT+1, |
| 953 #endif /* U_HIDE_DRAFT_API */ |
| 954 |
| 955 /* The following cannot be #ifndef U_HIDE_INTERNAL_API, needed in .h file vari
able declararions */ |
914 /** Limit of boolean attributes. | 956 /** Limit of boolean attributes. |
915 * @internal */ | 957 * @internal */ |
916 UNUM_LIMIT_BOOLEAN_ATTRIBUTE | 958 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = UNUM_PARSE_NO_EXPONENT+2 |
917 #endif /* U_HIDE_INTERNAL_API */ | |
918 } UNumberFormatAttribute; | 959 } UNumberFormatAttribute; |
919 | 960 |
920 /** | 961 /** |
921 * Get a numeric attribute associated with a UNumberFormat. | 962 * Get a numeric attribute associated with a UNumberFormat. |
922 * An example of a numeric attribute is the number of integer digits a formatter
will produce. | 963 * An example of a numeric attribute is the number of integer digits a formatter
will produce. |
923 * @param fmt The formatter to query. | 964 * @param fmt The formatter to query. |
924 * @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_
USED, | 965 * @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_
USED, |
925 * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, U
NUM_INTEGER_DIGITS, | 966 * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, U
NUM_INTEGER_DIGITS, |
926 * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM
_MULTIPLIER, | 967 * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM
_MULTIPLIER, |
927 * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITI
ON, UNUM_SECONDARY_GROUPING_SIZE, | 968 * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITI
ON, UNUM_SECONDARY_GROUPING_SIZE, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 UNUM_POSITIVE_SUFFIX, | 1049 UNUM_POSITIVE_SUFFIX, |
1009 /** Negative prefix */ | 1050 /** Negative prefix */ |
1010 UNUM_NEGATIVE_PREFIX, | 1051 UNUM_NEGATIVE_PREFIX, |
1011 /** Negative suffix */ | 1052 /** Negative suffix */ |
1012 UNUM_NEGATIVE_SUFFIX, | 1053 UNUM_NEGATIVE_SUFFIX, |
1013 /** The character used to pad to the format width. */ | 1054 /** The character used to pad to the format width. */ |
1014 UNUM_PADDING_CHARACTER, | 1055 UNUM_PADDING_CHARACTER, |
1015 /** The ISO currency code */ | 1056 /** The ISO currency code */ |
1016 UNUM_CURRENCY_CODE, | 1057 UNUM_CURRENCY_CODE, |
1017 /** | 1058 /** |
1018 * The default rule set. This is only available with rule-based formatters. | 1059 * The default rule set, such as "%spellout-numbering-year:", "%spellout-cardi
nal:", |
| 1060 * "%spellout-ordinal-masculine-plural:", "%spellout-ordinal-feminine:", or |
| 1061 * "%spellout-ordinal-neuter:". The available public rulesets can be listed us
ing |
| 1062 * unum_getTextAttribute with UNUM_PUBLIC_RULESETS. This is only available wit
h |
| 1063 * rule-based formatters. |
1019 * @stable ICU 3.0 | 1064 * @stable ICU 3.0 |
1020 */ | 1065 */ |
1021 UNUM_DEFAULT_RULESET, | 1066 UNUM_DEFAULT_RULESET, |
1022 /** | 1067 /** |
1023 * The public rule sets. This is only available with rule-based formatters. | 1068 * The public rule sets. This is only available with rule-based formatters. |
1024 * This is a read-only attribute. The public rulesets are returned as a | 1069 * This is a read-only attribute. The public rulesets are returned as a |
1025 * single string, with each ruleset name delimited by ';' (semicolon). | 1070 * single string, with each ruleset name delimited by ';' (semicolon). See the |
| 1071 * CLDR LDML spec for more information about RBNF rulesets: |
| 1072 * http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_For
matting |
1026 * @stable ICU 3.0 | 1073 * @stable ICU 3.0 |
1027 */ | 1074 */ |
1028 UNUM_PUBLIC_RULESETS | 1075 UNUM_PUBLIC_RULESETS |
1029 } UNumberFormatTextAttribute; | 1076 } UNumberFormatTextAttribute; |
1030 | 1077 |
1031 /** | 1078 /** |
1032 * Get a text attribute associated with a UNumberFormat. | 1079 * Get a text attribute associated with a UNumberFormat. |
1033 * An example of a text attribute is the suffix for positive numbers. If the for
matter | 1080 * An example of a text attribute is the suffix for positive numbers. If the for
matter |
1034 * does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the stat
us. | 1081 * does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the stat
us. |
1035 * Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RUL
ESETS. | 1082 * Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RUL
ESETS. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 */ | 1220 */ |
1174 UNUM_SEVEN_DIGIT_SYMBOL = 24, | 1221 UNUM_SEVEN_DIGIT_SYMBOL = 24, |
1175 /** Eight | 1222 /** Eight |
1176 * @stable ICU 4.6 | 1223 * @stable ICU 4.6 |
1177 */ | 1224 */ |
1178 UNUM_EIGHT_DIGIT_SYMBOL = 25, | 1225 UNUM_EIGHT_DIGIT_SYMBOL = 25, |
1179 /** Nine | 1226 /** Nine |
1180 * @stable ICU 4.6 | 1227 * @stable ICU 4.6 |
1181 */ | 1228 */ |
1182 UNUM_NINE_DIGIT_SYMBOL = 26, | 1229 UNUM_NINE_DIGIT_SYMBOL = 26, |
| 1230 |
| 1231 #ifndef U_HIDE_DRAFT_API |
| 1232 /** Multiplication sign |
| 1233 * @draft ICU 54 |
| 1234 */ |
| 1235 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, |
| 1236 #endif /* U_HIDE_DRAFT_API */ |
| 1237 |
1183 /** count symbol constants */ | 1238 /** count symbol constants */ |
1184 UNUM_FORMAT_SYMBOL_COUNT = 27 | 1239 UNUM_FORMAT_SYMBOL_COUNT = 28 |
1185 } UNumberFormatSymbol; | 1240 } UNumberFormatSymbol; |
1186 | 1241 |
1187 /** | 1242 /** |
1188 * Get a symbol associated with a UNumberFormat. | 1243 * Get a symbol associated with a UNumberFormat. |
1189 * A UNumberFormat uses symbols to represent the special locale-dependent | 1244 * A UNumberFormat uses symbols to represent the special locale-dependent |
1190 * characters in a number, for example the percent sign. This API is not | 1245 * characters in a number, for example the percent sign. This API is not |
1191 * supported for rule-based formatters. | 1246 * supported for rule-based formatters. |
1192 * @param fmt The formatter to query. | 1247 * @param fmt The formatter to query. |
1193 * @param symbol The UNumberFormatSymbol constant for the symbol to get | 1248 * @param symbol The UNumberFormatSymbol constant for the symbol to get |
1194 * @param buffer The string buffer that will receive the symbol string; | 1249 * @param buffer The string buffer that will receive the symbol string; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 * @param type type of the locale we're looking for (valid or actual) | 1290 * @param type type of the locale we're looking for (valid or actual) |
1236 * @param status error code for the operation | 1291 * @param status error code for the operation |
1237 * @return the locale name | 1292 * @return the locale name |
1238 * @stable ICU 2.8 | 1293 * @stable ICU 2.8 |
1239 */ | 1294 */ |
1240 U_STABLE const char* U_EXPORT2 | 1295 U_STABLE const char* U_EXPORT2 |
1241 unum_getLocaleByType(const UNumberFormat *fmt, | 1296 unum_getLocaleByType(const UNumberFormat *fmt, |
1242 ULocDataLocaleType type, | 1297 ULocDataLocaleType type, |
1243 UErrorCode* status); | 1298 UErrorCode* status); |
1244 | 1299 |
| 1300 #ifndef U_HIDE_DRAFT_API |
| 1301 /** |
| 1302 * Set a particular UDisplayContext value in the formatter, such as |
| 1303 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. |
| 1304 * @param fmt The formatter for which to set a UDisplayContext value. |
| 1305 * @param value The UDisplayContext value to set. |
| 1306 * @param status A pointer to an UErrorCode to receive any errors |
| 1307 * @draft ICU 53 |
| 1308 */ |
| 1309 U_DRAFT void U_EXPORT2 |
| 1310 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status); |
| 1311 |
| 1312 /** |
| 1313 * Get the formatter's UDisplayContext value for the specified UDisplayContextTy
pe, |
| 1314 * such as UDISPCTX_TYPE_CAPITALIZATION. |
| 1315 * @param fmt The formatter to query. |
| 1316 * @param type The UDisplayContextType whose value to return |
| 1317 * @param status A pointer to an UErrorCode to receive any errors |
| 1318 * @return The UDisplayContextValue for the specified type. |
| 1319 * @draft ICU 53 |
| 1320 */ |
| 1321 U_DRAFT UDisplayContext U_EXPORT2 |
| 1322 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode*
status); |
| 1323 |
| 1324 #endif /* U_HIDE_DRAFT_API */ |
| 1325 |
1245 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1326 #endif /* #if !UCONFIG_NO_FORMATTING */ |
1246 | 1327 |
1247 #endif | 1328 #endif |
OLD | NEW |