ICU 71.1: unum.h Source File

ICU 71.1 71.1

unum.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4*******************************************************************************
5* Copyright (C) 1997-2015, International Business Machines Corporation and others.
6* All Rights Reserved.
7* Modification History:
8*
9* Date Name Description
10* 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes
11*******************************************************************************
12*/
13
14#ifndef _UNUM
15#define _UNUM
16
17#include "unicode/utypes.h"
18
19#if !UCONFIG_NO_FORMATTING
20
21#include "unicode/uloc.h"
22#include "unicode/ucurr.h"
23#include "unicode/umisc.h"
24#include "unicode/parseerr.h"
25#include "unicode/uformattable.h"
26#include "unicode/udisplaycontext.h"
27#include "unicode/ufieldpositer.h"
28
29#if U_SHOW_CPLUSPLUS_API
30#include "unicode/localpointer.h"
31#endif // U_SHOW_CPLUSPLUS_API
32
144 typedef void* UNumberFormat;
145
149 typedef enum UNumberFormatStyle {
154 UNUM_PATTERN_DECIMAL=0,
159 UNUM_DECIMAL=1,
168 UNUM_CURRENCY=2,
173 UNUM_PERCENT=3,
178 UNUM_SCIENTIFIC=4,
185 UNUM_SPELLOUT=5,
192 UNUM_ORDINAL=6,
197 UNUM_DURATION=7,
202 UNUM_NUMBERING_SYSTEM=8,
207 UNUM_PATTERN_RULEBASED=9,
212 UNUM_CURRENCY_ISO=10,
218 UNUM_CURRENCY_PLURAL=11,
225 UNUM_CURRENCY_ACCOUNTING=12,
231 UNUM_CASH_CURRENCY=13,
238 UNUM_DECIMAL_COMPACT_SHORT=14,
245 UNUM_DECIMAL_COMPACT_LONG=15,
252 UNUM_CURRENCY_STANDARD=16,
253
254#ifndef U_HIDE_DEPRECATED_API
259 UNUM_FORMAT_STYLE_COUNT=17,
260#endif /* U_HIDE_DEPRECATED_API */
261
266 UNUM_DEFAULT = UNUM_DECIMAL,
271 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
272} UNumberFormatStyle;
273
282 typedef enum UNumberFormatRoundingMode {
283 UNUM_ROUND_CEILING,
284 UNUM_ROUND_FLOOR,
285 UNUM_ROUND_DOWN,
286 UNUM_ROUND_UP,
291 UNUM_ROUND_HALFEVEN,
292#ifndef U_HIDE_DEPRECATED_API
297 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
298#endif /* U_HIDE_DEPRECATED_API */
299 UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
300 UNUM_ROUND_HALFUP,
305 UNUM_ROUND_UNNECESSARY,
310 UNUM_ROUND_HALF_ODD,
315 UNUM_ROUND_HALF_CEILING,
320 UNUM_ROUND_HALF_FLOOR,
321} UNumberFormatRoundingMode;
322
326 typedef enum UNumberFormatPadPosition {
327 UNUM_PAD_BEFORE_PREFIX,
328 UNUM_PAD_AFTER_PREFIX,
329 UNUM_PAD_BEFORE_SUFFIX,
330 UNUM_PAD_AFTER_SUFFIX
331} UNumberFormatPadPosition;
332
337 typedef enum UNumberCompactStyle {
339 UNUM_SHORT,
341 UNUM_LONG
343} UNumberCompactStyle;
344
349 enum UCurrencySpacing {
351 UNUM_CURRENCY_MATCH,
353 UNUM_CURRENCY_SURROUNDING_MATCH,
355 UNUM_CURRENCY_INSERT,
356
357 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
358 * it is needed for layout of DecimalFormatSymbols object. */
359#ifndef U_FORCE_HIDE_DEPRECATED_API
364 UNUM_CURRENCY_SPACING_COUNT
365#endif // U_FORCE_HIDE_DEPRECATED_API
366};
367 typedef enum UCurrencySpacing UCurrencySpacing;
375 typedef enum UNumberFormatFields {
377 UNUM_INTEGER_FIELD,
379 UNUM_FRACTION_FIELD,
381 UNUM_DECIMAL_SEPARATOR_FIELD,
383 UNUM_EXPONENT_SYMBOL_FIELD,
385 UNUM_EXPONENT_SIGN_FIELD,
387 UNUM_EXPONENT_FIELD,
389 UNUM_GROUPING_SEPARATOR_FIELD,
391 UNUM_CURRENCY_FIELD,
393 UNUM_PERCENT_FIELD,
395 UNUM_PERMILL_FIELD,
397 UNUM_SIGN_FIELD,
399 UNUM_MEASURE_UNIT_FIELD,
401 UNUM_COMPACT_FIELD,
402#ifndef U_HIDE_DRAFT_API
407 UNUM_APPROXIMATELY_SIGN_FIELD,
408#endif // U_HIDE_DRAFT_API
409
410#ifndef U_HIDE_DEPRECATED_API
415#ifndef U_HIDE_DRAFT_API
416 UNUM_FIELD_COUNT = UNUM_COMPACT_FIELD + 2
417#else // U_HIDE_DRAFT_API (for UNUM_APPROXIMATELY_SIGN_FIELD)
418 UNUM_FIELD_COUNT = UNUM_COMPACT_FIELD + 1
419#endif // U_HIDE_DRAFT_API (for UNUM_APPROXIMATELY_SIGN_FIELD)
420#endif /* U_HIDE_DEPRECATED_API */
421} UNumberFormatFields;
422
423
431 typedef enum UNumberFormatMinimumGroupingDigits {
436 UNUM_MINIMUM_GROUPING_DIGITS_AUTO = -2,
443 UNUM_MINIMUM_GROUPING_DIGITS_MIN2 = -3,
444} UNumberFormatMinimumGroupingDigits;
445
483 U_CAPI UNumberFormat* U_EXPORT2
484unum_open( UNumberFormatStyle style,
485 const UChar* pattern,
486 int32_t patternLength,
487 const char* locale,
488 UParseError* parseErr,
489 UErrorCode* status);
490
491
498 U_CAPI void U_EXPORT2
499unum_close(UNumberFormat* fmt);
500
501#if U_SHOW_CPLUSPLUS_API
502
503U_NAMESPACE_BEGIN
504
514 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
515
516U_NAMESPACE_END
517
518#endif
519
528 U_CAPI UNumberFormat* U_EXPORT2
529unum_clone(const UNumberFormat *fmt,
530 UErrorCode *status);
531
556 U_CAPI int32_t U_EXPORT2
557unum_format( const UNumberFormat* fmt,
558 int32_t number,
559 UChar* result,
560 int32_t resultLength,
561 UFieldPosition *pos,
562 UErrorCode* status);
563
588 U_CAPI int32_t U_EXPORT2
589unum_formatInt64(const UNumberFormat *fmt,
590 int64_t number,
591 UChar* result,
592 int32_t resultLength,
593 UFieldPosition *pos,
594 UErrorCode* status);
595
620 U_CAPI int32_t U_EXPORT2
621unum_formatDouble( const UNumberFormat* fmt,
622 double number,
623 UChar* result,
624 int32_t resultLength,
625 UFieldPosition *pos, /* 0 if ignore */
626 UErrorCode* status);
627
670 U_CAPI int32_t U_EXPORT2
671unum_formatDoubleForFields(const UNumberFormat* format,
672 double number,
673 UChar* result,
674 int32_t resultLength,
675 UFieldPositionIterator* fpositer,
676 UErrorCode* status);
677
678
707 U_CAPI int32_t U_EXPORT2
708unum_formatDecimal( const UNumberFormat* fmt,
709 const char * number,
710 int32_t length,
711 UChar* result,
712 int32_t resultLength,
713 UFieldPosition *pos, /* 0 if ignore */
714 UErrorCode* status);
715
746 U_CAPI int32_t U_EXPORT2
747unum_formatDoubleCurrency(const UNumberFormat* fmt,
748 double number,
749 UChar* currency,
750 UChar* result,
751 int32_t resultLength,
752 UFieldPosition* pos,
753 UErrorCode* status);
754
775 U_CAPI int32_t U_EXPORT2
776unum_formatUFormattable(const UNumberFormat* fmt,
777 const UFormattable *number,
778 UChar *result,
779 int32_t resultLength,
780 UFieldPosition *pos,
781 UErrorCode *status);
782
802 U_CAPI int32_t U_EXPORT2
803unum_parse( const UNumberFormat* fmt,
804 const UChar* text,
805 int32_t textLength,
806 int32_t *parsePos /* 0 = start */,
807 UErrorCode *status);
808
828 U_CAPI int64_t U_EXPORT2
829unum_parseInt64(const UNumberFormat* fmt,
830 const UChar* text,
831 int32_t textLength,
832 int32_t *parsePos /* 0 = start */,
833 UErrorCode *status);
834
854 U_CAPI double U_EXPORT2
855unum_parseDouble( const UNumberFormat* fmt,
856 const UChar* text,
857 int32_t textLength,
858 int32_t *parsePos /* 0 = start */,
859 UErrorCode *status);
860
861
889 U_CAPI int32_t U_EXPORT2
890unum_parseDecimal(const UNumberFormat* fmt,
891 const UChar* text,
892 int32_t textLength,
893 int32_t *parsePos /* 0 = start */,
894 char *outBuf,
895 int32_t outBufLength,
896 UErrorCode *status);
897
917 U_CAPI double U_EXPORT2
918unum_parseDoubleCurrency(const UNumberFormat* fmt,
919 const UChar* text,
920 int32_t textLength,
921 int32_t* parsePos, /* 0 = start */
922 UChar* currency,
923 UErrorCode* status);
924
945 U_CAPI UFormattable* U_EXPORT2
946unum_parseToUFormattable(const UNumberFormat* fmt,
947 UFormattable *result,
948 const UChar* text,
949 int32_t textLength,
950 int32_t* parsePos, /* 0 = start */
951 UErrorCode* status);
952
969 U_CAPI void U_EXPORT2
970unum_applyPattern( UNumberFormat *format,
971 UBool localized,
972 const UChar *pattern,
973 int32_t patternLength,
974 UParseError *parseError,
975 UErrorCode *status
976 );
977
988 U_CAPI const char* U_EXPORT2
989unum_getAvailable(int32_t localeIndex);
990
1000 U_CAPI int32_t U_EXPORT2
1001unum_countAvailable(void);
1002
1003#if UCONFIG_HAVE_PARSEALLINPUT
1004/* The UNumberFormatAttributeValue type cannot be #ifndef U_HIDE_INTERNAL_API, needed for .h variable declaration */
1008typedef enum UNumberFormatAttributeValue {
1009#ifndef U_HIDE_INTERNAL_API
1011 UNUM_NO = 0,
1013 UNUM_YES = 1,
1015 UNUM_MAYBE = 2
1016#else
1018 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
1019#endif /* U_HIDE_INTERNAL_API */
1020} UNumberFormatAttributeValue;
1021#endif
1022
1024 typedef enum UNumberFormatAttribute {
1026 UNUM_PARSE_INT_ONLY,
1028 UNUM_GROUPING_USED,
1030 UNUM_DECIMAL_ALWAYS_SHOWN,
1032 UNUM_MAX_INTEGER_DIGITS,
1034 UNUM_MIN_INTEGER_DIGITS,
1036 UNUM_INTEGER_DIGITS,
1038 UNUM_MAX_FRACTION_DIGITS,
1040 UNUM_MIN_FRACTION_DIGITS,
1042 UNUM_FRACTION_DIGITS,
1044 UNUM_MULTIPLIER,
1046 UNUM_GROUPING_SIZE,
1048 UNUM_ROUNDING_MODE,
1050 UNUM_ROUNDING_INCREMENT,
1052 UNUM_FORMAT_WIDTH,
1054 UNUM_PADDING_POSITION,
1056 UNUM_SECONDARY_GROUPING_SIZE,
1059 UNUM_SIGNIFICANT_DIGITS_USED,
1062 UNUM_MIN_SIGNIFICANT_DIGITS,
1065 UNUM_MAX_SIGNIFICANT_DIGITS,
1069 UNUM_LENIENT_PARSE,
1070#if UCONFIG_HAVE_PARSEALLINPUT
1075 UNUM_PARSE_ALL_INPUT = 20,
1076#endif
1088 UNUM_SCALE = 21,
1089
1098 UNUM_MINIMUM_GROUPING_DIGITS = 22,
1099
1106 UNUM_CURRENCY_USAGE = 23,
1107
1108#ifndef U_HIDE_INTERNAL_API
1112 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
1113#endif /* U_HIDE_INTERNAL_API */
1114
1120 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
1127 UNUM_PARSE_NO_EXPONENT = 0x1001,
1128
1137 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
1138
1144 UNUM_PARSE_CASE_SENSITIVE = 0x1003,
1145
1153 UNUM_SIGN_ALWAYS_SHOWN = 0x1004,
1154
1155#ifndef U_HIDE_INTERNAL_API
1159 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005,
1160#endif /* U_HIDE_INTERNAL_API */
1161
1162} UNumberFormatAttribute;
1163
1181 U_CAPI int32_t U_EXPORT2
1182unum_getAttribute(const UNumberFormat* fmt,
1183 UNumberFormatAttribute attr);
1184
1204 U_CAPI void U_EXPORT2
1205unum_setAttribute( UNumberFormat* fmt,
1206 UNumberFormatAttribute attr,
1207 int32_t newValue);
1208
1209
1224 U_CAPI double U_EXPORT2
1225unum_getDoubleAttribute(const UNumberFormat* fmt,
1226 UNumberFormatAttribute attr);
1227
1242 U_CAPI void U_EXPORT2
1243unum_setDoubleAttribute( UNumberFormat* fmt,
1244 UNumberFormatAttribute attr,
1245 double newValue);
1246
1248 typedef enum UNumberFormatTextAttribute {
1250 UNUM_POSITIVE_PREFIX,
1252 UNUM_POSITIVE_SUFFIX,
1254 UNUM_NEGATIVE_PREFIX,
1256 UNUM_NEGATIVE_SUFFIX,
1258 UNUM_PADDING_CHARACTER,
1260 UNUM_CURRENCY_CODE,
1269 UNUM_DEFAULT_RULESET,
1278 UNUM_PUBLIC_RULESETS
1279} UNumberFormatTextAttribute;
1280
1299 U_CAPI int32_t U_EXPORT2
1300unum_getTextAttribute( const UNumberFormat* fmt,
1301 UNumberFormatTextAttribute tag,
1302 UChar* result,
1303 int32_t resultLength,
1304 UErrorCode* status);
1305
1322 U_CAPI void U_EXPORT2
1323unum_setTextAttribute( UNumberFormat* fmt,
1324 UNumberFormatTextAttribute tag,
1325 const UChar* newValue,
1326 int32_t newValueLength,
1327 UErrorCode *status);
1328
1345 U_CAPI int32_t U_EXPORT2
1346unum_toPattern( const UNumberFormat* fmt,
1347 UBool isPatternLocalized,
1348 UChar* result,
1349 int32_t resultLength,
1350 UErrorCode* status);
1351
1352
1357 typedef enum UNumberFormatSymbol {
1359 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
1361 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
1363 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
1365 UNUM_PERCENT_SYMBOL = 3,
1367 UNUM_ZERO_DIGIT_SYMBOL = 4,
1369 UNUM_DIGIT_SYMBOL = 5,
1371 UNUM_MINUS_SIGN_SYMBOL = 6,
1373 UNUM_PLUS_SIGN_SYMBOL = 7,
1375 UNUM_CURRENCY_SYMBOL = 8,
1377 UNUM_INTL_CURRENCY_SYMBOL = 9,
1379 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
1381 UNUM_EXPONENTIAL_SYMBOL = 11,
1383 UNUM_PERMILL_SYMBOL = 12,
1385 UNUM_PAD_ESCAPE_SYMBOL = 13,
1387 UNUM_INFINITY_SYMBOL = 14,
1389 UNUM_NAN_SYMBOL = 15,
1392 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
1396 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
1400 UNUM_ONE_DIGIT_SYMBOL = 18,
1404 UNUM_TWO_DIGIT_SYMBOL = 19,
1408 UNUM_THREE_DIGIT_SYMBOL = 20,
1412 UNUM_FOUR_DIGIT_SYMBOL = 21,
1416 UNUM_FIVE_DIGIT_SYMBOL = 22,
1420 UNUM_SIX_DIGIT_SYMBOL = 23,
1424 UNUM_SEVEN_DIGIT_SYMBOL = 24,
1428 UNUM_EIGHT_DIGIT_SYMBOL = 25,
1432 UNUM_NINE_DIGIT_SYMBOL = 26,
1433
1437 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
1438
1439#ifndef U_HIDE_INTERNAL_API
1443 UNUM_APPROXIMATELY_SIGN_SYMBOL = 28,
1444#endif
1445
1446#ifndef U_HIDE_DEPRECATED_API
1451 UNUM_FORMAT_SYMBOL_COUNT = 29
1452#endif /* U_HIDE_DEPRECATED_API */
1453} UNumberFormatSymbol;
1454
1471 U_CAPI int32_t U_EXPORT2
1472unum_getSymbol(const UNumberFormat *fmt,
1473 UNumberFormatSymbol symbol,
1474 UChar *buffer,
1475 int32_t size,
1476 UErrorCode *status);
1477
1491 U_CAPI void U_EXPORT2
1492unum_setSymbol(UNumberFormat *fmt,
1493 UNumberFormatSymbol symbol,
1494 const UChar *value,
1495 int32_t length,
1496 UErrorCode *status);
1497
1498
1508 U_CAPI const char* U_EXPORT2
1509unum_getLocaleByType(const UNumberFormat *fmt,
1510 ULocDataLocaleType type,
1511 UErrorCode* status);
1512
1521 U_CAPI void U_EXPORT2
1522unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
1523
1533 U_CAPI UDisplayContext U_EXPORT2
1534unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
1535
1536#endif /* #if !UCONFIG_NO_FORMATTING */
1537
1538#endif
LocalUNumberFormatPointer
"Smart pointer" class, closes a UNumberFormat via unum_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
parseerr.h
C API: Parse Error Information.
UFieldPosition
A struct representing a range of text containing a specific field.
Definition: umisc.h:34
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
ucurr.h
C API: Encapsulates information about a currency.
udisplaycontext.h
C API: Display context types (enum values)
UDisplayContextType
UDisplayContextType
Display context types, for getting values of a particular setting.
Definition: udisplaycontext.h:27
UDisplayContext
UDisplayContext
Display context settings.
Definition: udisplaycontext.h:64
ufieldpositer.h
C API: UFieldPositionIterator for use with format APIs.
UFieldPositionIterator
struct UFieldPositionIterator UFieldPositionIterator
C typedef for struct UFieldPositionIterator.
Definition: ufieldpositer.h:46
uformattable.h
C API: UFormattable is a thin wrapper for primitive types used for formatting and parsing.
UFormattable
void * UFormattable
Opaque type representing various types of data which may be used for formatting and parsing operation...
Definition: uformattable.h:72
uloc.h
C API: Locale.
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:418
umisc.h
C API:misc definitions.
unum_format
U_CAPI int32_t unum_format(const UNumberFormat *fmt, int32_t number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format an integer using a UNumberFormat.
unum_parseDecimal
U_CAPI int32_t unum_parseDecimal(const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, char *outBuf, int32_t outBufLength, UErrorCode *status)
Parse a number from a string into an unformatted numeric string using a UNumberFormat.
unum_setContext
U_CAPI void unum_setContext(UNumberFormat *fmt, UDisplayContext value, UErrorCode *status)
Set a particular UDisplayContext value in the formatter, such as UDISPCTX_CAPITALIZATION_FOR_STANDALO...
unum_formatDouble
U_CAPI int32_t unum_formatDouble(const UNumberFormat *fmt, double number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format a double using a UNumberFormat.
UNumberFormatAttribute
UNumberFormatAttribute
The possible UNumberFormat numeric attributes.
Definition: unum.h:1024
UNUM_GROUPING_SIZE
@ UNUM_GROUPING_SIZE
Grouping size.
Definition: unum.h:1046
UNUM_LENIENT_PARSE
@ UNUM_LENIENT_PARSE
Lenient parse mode used by rule-based formats.
Definition: unum.h:1069
UNUM_MIN_SIGNIFICANT_DIGITS
@ UNUM_MIN_SIGNIFICANT_DIGITS
Minimum significant digits.
Definition: unum.h:1062
UNUM_MAX_INTEGER_DIGITS
@ UNUM_MAX_INTEGER_DIGITS
Maximum integer digits.
Definition: unum.h:1032
UNUM_MAX_FRACTION_DIGITS
@ UNUM_MAX_FRACTION_DIGITS
Maximum fraction digits.
Definition: unum.h:1038
UNUM_PARSE_NO_EXPONENT
@ UNUM_PARSE_NO_EXPONENT
if this attribute is set to 1, specifies that, if the pattern doesn't contain an exponent,...
Definition: unum.h:1127
UNUM_FORMAT_WIDTH
@ UNUM_FORMAT_WIDTH
The width to which the output of format() is padded.
Definition: unum.h:1052
UNUM_LIMIT_BOOLEAN_ATTRIBUTE
@ UNUM_LIMIT_BOOLEAN_ATTRIBUTE
Limit of boolean attributes.
Definition: unum.h:1159
UNUM_PARSE_INT_ONLY
@ UNUM_PARSE_INT_ONLY
Parse integers only.
Definition: unum.h:1026
UNUM_MULTIPLIER
@ UNUM_MULTIPLIER
Multiplier.
Definition: unum.h:1044
UNUM_ROUNDING_INCREMENT
@ UNUM_ROUNDING_INCREMENT
Rounding increment.
Definition: unum.h:1050
UNUM_PARSE_CASE_SENSITIVE
@ UNUM_PARSE_CASE_SENSITIVE
Parsing: if set to 1, parsing is sensitive to case (lowercase/uppercase).
Definition: unum.h:1144
UNUM_SIGNIFICANT_DIGITS_USED
@ UNUM_SIGNIFICANT_DIGITS_USED
Use significant digits.
Definition: unum.h:1059
UNUM_MINIMUM_GROUPING_DIGITS
@ UNUM_MINIMUM_GROUPING_DIGITS
Minimum grouping digits; most commonly set to 2 to print "1000" instead of "1,000".
Definition: unum.h:1098
UNUM_SECONDARY_GROUPING_SIZE
@ UNUM_SECONDARY_GROUPING_SIZE
Secondary grouping size.
Definition: unum.h:1056
UNUM_MIN_FRACTION_DIGITS
@ UNUM_MIN_FRACTION_DIGITS
Minimum fraction digits.
Definition: unum.h:1040
UNUM_DECIMAL_ALWAYS_SHOWN
@ UNUM_DECIMAL_ALWAYS_SHOWN
Always show decimal point.
Definition: unum.h:1030
UNUM_MAX_SIGNIFICANT_DIGITS
@ UNUM_MAX_SIGNIFICANT_DIGITS
Maximum significant digits.
Definition: unum.h:1065
UNUM_INTEGER_DIGITS
@ UNUM_INTEGER_DIGITS
Integer digits.
Definition: unum.h:1036
UNUM_FRACTION_DIGITS
@ UNUM_FRACTION_DIGITS
Fraction digits.
Definition: unum.h:1042
UNUM_PARSE_DECIMAL_MARK_REQUIRED
@ UNUM_PARSE_DECIMAL_MARK_REQUIRED
if this attribute is set to 1, specifies that, if the pattern contains a decimal mark the input is re...
Definition: unum.h:1137
UNUM_SIGN_ALWAYS_SHOWN
@ UNUM_SIGN_ALWAYS_SHOWN
Formatting: if set to 1, whether to show the plus sign on non-negative numbers.
Definition: unum.h:1153
UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS
@ UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS
If 1, specifies that if setting the "max integer digits" attribute would truncate a value,...
Definition: unum.h:1120
UNUM_CURRENCY_USAGE
@ UNUM_CURRENCY_USAGE
if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose, otherwise it is UNUM_CASH...
Definition: unum.h:1106
UNUM_ROUNDING_MODE
@ UNUM_ROUNDING_MODE
Rounding Mode.
Definition: unum.h:1048
UNUM_SCALE
@ UNUM_SCALE
Scale, which adjusts the position of the decimal point when formatting.
Definition: unum.h:1088
UNUM_PADDING_POSITION
@ UNUM_PADDING_POSITION
The position at which padding will take place.
Definition: unum.h:1054
UNUM_MAX_NONBOOLEAN_ATTRIBUTE
@ UNUM_MAX_NONBOOLEAN_ATTRIBUTE
One below the first bitfield-boolean item.
Definition: unum.h:1112
UNUM_MIN_INTEGER_DIGITS
@ UNUM_MIN_INTEGER_DIGITS
Minimum integer digits.
Definition: unum.h:1034
UNUM_GROUPING_USED
@ UNUM_GROUPING_USED
Use grouping separator.
Definition: unum.h:1028
unum_clone
U_CAPI UNumberFormat * unum_clone(const UNumberFormat *fmt, UErrorCode *status)
Open a copy of a UNumberFormat.
unum_setTextAttribute
U_CAPI void unum_setTextAttribute(UNumberFormat *fmt, UNumberFormatTextAttribute tag, const UChar *newValue, int32_t newValueLength, UErrorCode *status)
Set a text attribute associated with a UNumberFormat.
UCurrencySpacing
UCurrencySpacing
Constants for specifying currency spacing.
Definition: unum.h:349
UNUM_CURRENCY_SPACING_COUNT
@ UNUM_CURRENCY_SPACING_COUNT
One more than the highest normal UCurrencySpacing value.
Definition: unum.h:364
UNUM_CURRENCY_SURROUNDING_MATCH
@ UNUM_CURRENCY_SURROUNDING_MATCH
Definition: unum.h:353
UNUM_CURRENCY_MATCH
@ UNUM_CURRENCY_MATCH
Definition: unum.h:351
UNUM_CURRENCY_INSERT
@ UNUM_CURRENCY_INSERT
Definition: unum.h:355
UNumberFormatRoundingMode
UNumberFormatRoundingMode
The possible number format rounding modes.
Definition: unum.h:282
UNUM_ROUND_UNNECESSARY
@ UNUM_ROUND_UNNECESSARY
ROUND_UNNECESSARY reports an error if formatted result is not exact.
Definition: unum.h:305
UNUM_ROUND_HALFEVEN
@ UNUM_ROUND_HALFEVEN
Half-even rounding.
Definition: unum.h:291
UNUM_ROUND_HALF_ODD
@ UNUM_ROUND_HALF_ODD
Rounds ties toward the odd number.
Definition: unum.h:310
UNUM_FOUND_HALFEVEN
@ UNUM_FOUND_HALFEVEN
Half-even rounding, misspelled name.
Definition: unum.h:297
UNUM_ROUND_HALF_FLOOR
@ UNUM_ROUND_HALF_FLOOR
Rounds ties toward -∞.
Definition: unum.h:320
UNUM_ROUND_HALF_CEILING
@ UNUM_ROUND_HALF_CEILING
Rounds ties toward +∞.
Definition: unum.h:315
unum_formatDoubleForFields
U_CAPI int32_t unum_formatDoubleForFields(const UNumberFormat *format, double number, UChar *result, int32_t resultLength, UFieldPositionIterator *fpositer, UErrorCode *status)
Format a double using a UNumberFormat according to the UNumberFormat's locale, and initialize a UFiel...
unum_formatInt64
U_CAPI int32_t unum_formatInt64(const UNumberFormat *fmt, int64_t number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format an int64 using a UNumberFormat.
unum_parseDouble
U_CAPI double unum_parseDouble(const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a string into a double using a UNumberFormat.
unum_formatDecimal
U_CAPI int32_t unum_formatDecimal(const UNumberFormat *fmt, const char *number, int32_t length, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format a decimal number using a UNumberFormat.
UNumberCompactStyle
UNumberCompactStyle
Constants for specifying short or long format.
Definition: unum.h:337
UNUM_LONG
@ UNUM_LONG
Definition: unum.h:341
UNUM_SHORT
@ UNUM_SHORT
Definition: unum.h:339
UNumberFormatStyle
UNumberFormatStyle
The possible number format styles.
Definition: unum.h:149
UNUM_CURRENCY
@ UNUM_CURRENCY
Currency format (generic).
Definition: unum.h:168
UNUM_SCIENTIFIC
@ UNUM_SCIENTIFIC
Scientific format.
Definition: unum.h:178
UNUM_CURRENCY_PLURAL
@ UNUM_CURRENCY_PLURAL
Currency format with a pluralized currency name, e.g., "1.00 US dollar" and "3.00 US dollars".
Definition: unum.h:218
UNUM_PATTERN_RULEBASED
@ UNUM_PATTERN_RULEBASED
Rule-based format defined by a pattern string.
Definition: unum.h:207
UNUM_SPELLOUT
@ UNUM_SPELLOUT
Spellout rule-based format.
Definition: unum.h:185
UNUM_DECIMAL_COMPACT_SHORT
@ UNUM_DECIMAL_COMPACT_SHORT
Decimal format expressed using compact notation (short form, corresponds to UNumberCompactStyle=UNUM_...
Definition: unum.h:238
UNUM_CASH_CURRENCY
@ UNUM_CASH_CURRENCY
Currency format with a currency symbol given CASH usage, e.g., "NT$3" instead of "NT$3....
Definition: unum.h:231
UNUM_DECIMAL_COMPACT_LONG
@ UNUM_DECIMAL_COMPACT_LONG
Decimal format expressed using compact notation (long form, corresponds to UNumberCompactStyle=UNUM_L...
Definition: unum.h:245
UNUM_FORMAT_STYLE_COUNT
@ UNUM_FORMAT_STYLE_COUNT
One more than the highest normal UNumberFormatStyle value.
Definition: unum.h:259
UNUM_PERCENT
@ UNUM_PERCENT
Percent format.
Definition: unum.h:173
UNUM_ORDINAL
@ UNUM_ORDINAL
Ordinal rule-based format .
Definition: unum.h:192
UNUM_CURRENCY_ISO
@ UNUM_CURRENCY_ISO
Currency format with an ISO currency code, e.g., "USD1.00".
Definition: unum.h:212
UNUM_NUMBERING_SYSTEM
@ UNUM_NUMBERING_SYSTEM
Numbering system rule-based format.
Definition: unum.h:202
UNUM_CURRENCY_STANDARD
@ UNUM_CURRENCY_STANDARD
Currency format with a currency symbol, e.g., "$1.00", using non-accounting style for negative values...
Definition: unum.h:252
UNUM_DEFAULT
@ UNUM_DEFAULT
Default format.
Definition: unum.h:266
UNUM_PATTERN_DECIMAL
@ UNUM_PATTERN_DECIMAL
Decimal format defined by a pattern string.
Definition: unum.h:154
UNUM_DURATION
@ UNUM_DURATION
Duration rule-based format.
Definition: unum.h:197
UNUM_CURRENCY_ACCOUNTING
@ UNUM_CURRENCY_ACCOUNTING
Currency format for accounting, e.g., "($3.00)" for negative currency amount instead of "-$3....
Definition: unum.h:225
UNUM_IGNORE
@ UNUM_IGNORE
Alias for UNUM_PATTERN_DECIMAL.
Definition: unum.h:271
UNUM_DECIMAL
@ UNUM_DECIMAL
Decimal format ("normal" style).
Definition: unum.h:159
unum_toPattern
U_CAPI int32_t unum_toPattern(const UNumberFormat *fmt, UBool isPatternLocalized, UChar *result, int32_t resultLength, UErrorCode *status)
Extract the pattern from a UNumberFormat.
unum_getDoubleAttribute
U_CAPI double unum_getDoubleAttribute(const UNumberFormat *fmt, UNumberFormatAttribute attr)
Get a numeric attribute associated with a UNumberFormat.
unum_getContext
U_CAPI UDisplayContext unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode *status)
Get the formatter's UDisplayContext value for the specified UDisplayContextType, such as UDISPCTX_TYP...
unum_countAvailable
U_CAPI int32_t unum_countAvailable(void)
Determine how many locales have decimal formatting patterns available.
unum_parseInt64
U_CAPI int64_t unum_parseInt64(const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a string into an int64 using a UNumberFormat.
unum_open
U_CAPI UNumberFormat * unum_open(UNumberFormatStyle style, const UChar *pattern, int32_t patternLength, const char *locale, UParseError *parseErr, UErrorCode *status)
Create and return a new UNumberFormat for formatting and parsing numbers.
UNumberFormatSymbol
UNumberFormatSymbol
Constants for specifying a number format symbol.
Definition: unum.h:1357
UNUM_FOUR_DIGIT_SYMBOL
@ UNUM_FOUR_DIGIT_SYMBOL
Four.
Definition: unum.h:1412
UNUM_PERMILL_SYMBOL
@ UNUM_PERMILL_SYMBOL
Per mill symbol.
Definition: unum.h:1383
UNUM_SIGNIFICANT_DIGIT_SYMBOL
@ UNUM_SIGNIFICANT_DIGIT_SYMBOL
Significant digit symbol.
Definition: unum.h:1392
UNUM_PAD_ESCAPE_SYMBOL
@ UNUM_PAD_ESCAPE_SYMBOL
Escape padding character.
Definition: unum.h:1385
UNUM_INFINITY_SYMBOL
@ UNUM_INFINITY_SYMBOL
Infinity symbol.
Definition: unum.h:1387
UNUM_TWO_DIGIT_SYMBOL
@ UNUM_TWO_DIGIT_SYMBOL
Two.
Definition: unum.h:1404
UNUM_EXPONENTIAL_SYMBOL
@ UNUM_EXPONENTIAL_SYMBOL
The exponential symbol.
Definition: unum.h:1381
UNUM_CURRENCY_SYMBOL
@ UNUM_CURRENCY_SYMBOL
The currency symbol.
Definition: unum.h:1375
UNUM_INTL_CURRENCY_SYMBOL
@ UNUM_INTL_CURRENCY_SYMBOL
The international currency symbol.
Definition: unum.h:1377
UNUM_FIVE_DIGIT_SYMBOL
@ UNUM_FIVE_DIGIT_SYMBOL
Five.
Definition: unum.h:1416
UNUM_EXPONENT_MULTIPLICATION_SYMBOL
@ UNUM_EXPONENT_MULTIPLICATION_SYMBOL
Multiplication sign.
Definition: unum.h:1437
UNUM_EIGHT_DIGIT_SYMBOL
@ UNUM_EIGHT_DIGIT_SYMBOL
Eight.
Definition: unum.h:1428
UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL
@ UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL
The monetary grouping separator.
Definition: unum.h:1396
UNUM_PERCENT_SYMBOL
@ UNUM_PERCENT_SYMBOL
The percent sign.
Definition: unum.h:1365
UNUM_PATTERN_SEPARATOR_SYMBOL
@ UNUM_PATTERN_SEPARATOR_SYMBOL
The pattern separator.
Definition: unum.h:1363
UNUM_DECIMAL_SEPARATOR_SYMBOL
@ UNUM_DECIMAL_SEPARATOR_SYMBOL
The decimal separator.
Definition: unum.h:1359
UNUM_PLUS_SIGN_SYMBOL
@ UNUM_PLUS_SIGN_SYMBOL
The plus sign.
Definition: unum.h:1373
UNUM_GROUPING_SEPARATOR_SYMBOL
@ UNUM_GROUPING_SEPARATOR_SYMBOL
The grouping separator.
Definition: unum.h:1361
UNUM_NAN_SYMBOL
@ UNUM_NAN_SYMBOL
Nan symbol.
Definition: unum.h:1389
UNUM_SIX_DIGIT_SYMBOL
@ UNUM_SIX_DIGIT_SYMBOL
Six.
Definition: unum.h:1420
UNUM_NINE_DIGIT_SYMBOL
@ UNUM_NINE_DIGIT_SYMBOL
Nine.
Definition: unum.h:1432
UNUM_APPROXIMATELY_SIGN_SYMBOL
@ UNUM_APPROXIMATELY_SIGN_SYMBOL
Approximately sign.
Definition: unum.h:1443
UNUM_MINUS_SIGN_SYMBOL
@ UNUM_MINUS_SIGN_SYMBOL
The minus sign.
Definition: unum.h:1371
UNUM_MONETARY_SEPARATOR_SYMBOL
@ UNUM_MONETARY_SEPARATOR_SYMBOL
The monetary separator.
Definition: unum.h:1379
UNUM_DIGIT_SYMBOL
@ UNUM_DIGIT_SYMBOL
Character representing a digit in the pattern.
Definition: unum.h:1369
UNUM_THREE_DIGIT_SYMBOL
@ UNUM_THREE_DIGIT_SYMBOL
Three.
Definition: unum.h:1408
UNUM_ZERO_DIGIT_SYMBOL
@ UNUM_ZERO_DIGIT_SYMBOL
Zero.
Definition: unum.h:1367
UNUM_ONE_DIGIT_SYMBOL
@ UNUM_ONE_DIGIT_SYMBOL
One.
Definition: unum.h:1400
UNUM_FORMAT_SYMBOL_COUNT
@ UNUM_FORMAT_SYMBOL_COUNT
One more than the highest normal UNumberFormatSymbol value.
Definition: unum.h:1451
UNUM_SEVEN_DIGIT_SYMBOL
@ UNUM_SEVEN_DIGIT_SYMBOL
Seven.
Definition: unum.h:1424
unum_parseDoubleCurrency
U_CAPI double unum_parseDoubleCurrency(const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UChar *currency, UErrorCode *status)
Parse a string into a double and a currency using a UNumberFormat.
UNumberFormatMinimumGroupingDigits
UNumberFormatMinimumGroupingDigits
Selectors with special numeric values to use locale default minimum grouping digits for the DecimalFo...
Definition: unum.h:431
UNUM_MINIMUM_GROUPING_DIGITS_MIN2
@ UNUM_MINIMUM_GROUPING_DIGITS_MIN2
Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (suc...
Definition: unum.h:443
UNUM_MINIMUM_GROUPING_DIGITS_AUTO
@ UNUM_MINIMUM_GROUPING_DIGITS_AUTO
Display grouping using the default strategy for all locales.
Definition: unum.h:436
unum_formatDoubleCurrency
U_CAPI int32_t unum_formatDoubleCurrency(const UNumberFormat *fmt, double number, UChar *currency, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format a double currency amount using a UNumberFormat.
unum_getAvailable
U_CAPI const char * unum_getAvailable(int32_t localeIndex)
Get a locale for which decimal formatting patterns are available.
unum_getTextAttribute
U_CAPI int32_t unum_getTextAttribute(const UNumberFormat *fmt, UNumberFormatTextAttribute tag, UChar *result, int32_t resultLength, UErrorCode *status)
Get a text attribute associated with a UNumberFormat.
unum_parseToUFormattable
U_CAPI UFormattable * unum_parseToUFormattable(const UNumberFormat *fmt, UFormattable *result, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a UChar string into a UFormattable.
unum_getAttribute
U_CAPI int32_t unum_getAttribute(const UNumberFormat *fmt, UNumberFormatAttribute attr)
Get a numeric attribute associated with a UNumberFormat.
unum_parse
U_CAPI int32_t unum_parse(const UNumberFormat *fmt, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a string into an integer using a UNumberFormat.
UNumberFormatTextAttribute
UNumberFormatTextAttribute
The possible UNumberFormat text attributes.
Definition: unum.h:1248
UNUM_NEGATIVE_PREFIX
@ UNUM_NEGATIVE_PREFIX
Negative prefix.
Definition: unum.h:1254
UNUM_POSITIVE_PREFIX
@ UNUM_POSITIVE_PREFIX
Positive prefix.
Definition: unum.h:1250
UNUM_DEFAULT_RULESET
@ UNUM_DEFAULT_RULESET
The default rule set, such as "%spellout-numbering-year:", "%spellout-cardinal:", "%spellout-ordinal-...
Definition: unum.h:1269
UNUM_PUBLIC_RULESETS
@ UNUM_PUBLIC_RULESETS
The public rule sets.
Definition: unum.h:1278
UNUM_PADDING_CHARACTER
@ UNUM_PADDING_CHARACTER
The character used to pad to the format width.
Definition: unum.h:1258
UNUM_CURRENCY_CODE
@ UNUM_CURRENCY_CODE
The ISO currency code.
Definition: unum.h:1260
UNUM_NEGATIVE_SUFFIX
@ UNUM_NEGATIVE_SUFFIX
Negative suffix.
Definition: unum.h:1256
UNUM_POSITIVE_SUFFIX
@ UNUM_POSITIVE_SUFFIX
Positive suffix.
Definition: unum.h:1252
unum_getSymbol
U_CAPI int32_t unum_getSymbol(const UNumberFormat *fmt, UNumberFormatSymbol symbol, UChar *buffer, int32_t size, UErrorCode *status)
Get a symbol associated with a UNumberFormat.
unum_setDoubleAttribute
U_CAPI void unum_setDoubleAttribute(UNumberFormat *fmt, UNumberFormatAttribute attr, double newValue)
Set a numeric attribute associated with a UNumberFormat.
UNumberFormat
void * UNumberFormat
A number formatter.
Definition: unum.h:144
unum_setAttribute
U_CAPI void unum_setAttribute(UNumberFormat *fmt, UNumberFormatAttribute attr, int32_t newValue)
Set a numeric attribute associated with a UNumberFormat.
UNumberFormatPadPosition
UNumberFormatPadPosition
The possible number format pad positions.
Definition: unum.h:326
unum_close
U_CAPI void unum_close(UNumberFormat *fmt)
Close a UNumberFormat.
UNumberFormatFields
UNumberFormatFields
FieldPosition and UFieldPosition selectors for format fields defined by NumberFormat and UNumberForma...
Definition: unum.h:375
UNUM_MEASURE_UNIT_FIELD
@ UNUM_MEASURE_UNIT_FIELD
Definition: unum.h:399
UNUM_COMPACT_FIELD
@ UNUM_COMPACT_FIELD
Definition: unum.h:401
UNUM_INTEGER_FIELD
@ UNUM_INTEGER_FIELD
Definition: unum.h:377
UNUM_PERCENT_FIELD
@ UNUM_PERCENT_FIELD
Definition: unum.h:393
UNUM_PERMILL_FIELD
@ UNUM_PERMILL_FIELD
Definition: unum.h:395
UNUM_EXPONENT_SYMBOL_FIELD
@ UNUM_EXPONENT_SYMBOL_FIELD
Definition: unum.h:383
UNUM_GROUPING_SEPARATOR_FIELD
@ UNUM_GROUPING_SEPARATOR_FIELD
Definition: unum.h:389
UNUM_DECIMAL_SEPARATOR_FIELD
@ UNUM_DECIMAL_SEPARATOR_FIELD
Definition: unum.h:381
UNUM_APPROXIMATELY_SIGN_FIELD
@ UNUM_APPROXIMATELY_SIGN_FIELD
Approximately sign.
Definition: unum.h:407
UNUM_SIGN_FIELD
@ UNUM_SIGN_FIELD
Definition: unum.h:397
UNUM_CURRENCY_FIELD
@ UNUM_CURRENCY_FIELD
Definition: unum.h:391
UNUM_FRACTION_FIELD
@ UNUM_FRACTION_FIELD
Definition: unum.h:379
UNUM_FIELD_COUNT
@ UNUM_FIELD_COUNT
One more than the highest normal UNumberFormatFields value.
Definition: unum.h:416
UNUM_EXPONENT_SIGN_FIELD
@ UNUM_EXPONENT_SIGN_FIELD
Definition: unum.h:385
UNUM_EXPONENT_FIELD
@ UNUM_EXPONENT_FIELD
Definition: unum.h:387
unum_setSymbol
U_CAPI void unum_setSymbol(UNumberFormat *fmt, UNumberFormatSymbol symbol, const UChar *value, int32_t length, UErrorCode *status)
Set a symbol associated with a UNumberFormat.
unum_applyPattern
U_CAPI void unum_applyPattern(UNumberFormat *format, UBool localized, const UChar *pattern, int32_t patternLength, UParseError *parseError, UErrorCode *status)
Set the pattern used by a UNumberFormat.
unum_formatUFormattable
U_CAPI int32_t unum_formatUFormattable(const UNumberFormat *fmt, const UFormattable *number, UChar *result, int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
Format a UFormattable into a string.
unum_getLocaleByType
U_CAPI const char * unum_getLocaleByType(const UNumberFormat *fmt, ULocDataLocaleType type, UErrorCode *status)
Get the locale for this number format object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415