ICU 70.1  70.1
unumberformatter.h
Go to the documentation of this file.
1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 
4 #ifndef __UNUMBERFORMATTER_H__
5 #define __UNUMBERFORMATTER_H__
6 
7 #include "unicode/utypes.h"
8 
9 #if !UCONFIG_NO_FORMATTING
10 
11 #include "unicode/parseerr.h"
12 #include "unicode/ufieldpositer.h"
13 #include "unicode/umisc.h"
15 
16 
81 #ifndef U_FORCE_HIDE_DRAFT_API
82 
127 
135 #endif // U_FORCE_HIDE_DRAFT_API
136 
155 typedef enum UNumberUnitWidth {
168 
184 
195 
206 
217 
228 
237 
238  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
239  // needed for unconditionalized struct MacroProps
247 
281 
297 
312 
328 
336 
337 #ifndef U_HIDE_INTERNAL_API
338  ,
345 #endif /* U_HIDE_INTERNAL_API */
346 
348 
368 typedef enum UNumberSignDisplay {
379 
387 
394 
410 
420 
428 
437 
438 #ifndef U_HIDE_DRAFT_API
439 
445 
452 #endif // U_HIDE_DRAFT_API
453 
454  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
455  // needed for unconditionalized struct MacroProps
463 
483 
490 
491  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
492  // needed for unconditionalized struct MacroProps
500 
501 #ifndef U_FORCE_HIDE_DRAFT_API
502 
517 
525 #endif // U_FORCE_HIDE_DRAFT_API
526 
527 struct UNumberFormatter;
536 
537 struct UFormattedNumber;
546 
547 
568 U_CAPI UNumberFormatter* U_EXPORT2
569 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
570  UErrorCode* ec);
571 
572 
588 U_CAPI UNumberFormatter* U_EXPORT2
590  const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
591 
592 
601 U_CAPI UFormattedNumber* U_EXPORT2
603 
604 
620 U_CAPI void U_EXPORT2
621 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
622  UErrorCode* ec);
623 
624 
640 U_CAPI void U_EXPORT2
641 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
642  UErrorCode* ec);
643 
644 
664 U_CAPI void U_EXPORT2
665 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
666  UFormattedNumber* uresult, UErrorCode* ec);
667 
682 U_CAPI const UFormattedValue* U_EXPORT2
683 unumf_resultAsValue(const UFormattedNumber* uresult, UErrorCode* ec);
684 
685 
705 U_CAPI int32_t U_EXPORT2
706 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
707  UErrorCode* ec);
708 
709 
743 U_CAPI UBool U_EXPORT2
745 
746 
768 U_CAPI void U_EXPORT2
770  UErrorCode* ec);
771 
772 
791 U_CAPI int32_t U_EXPORT2
793  const UFormattedNumber* uresult,
794  char* dest,
795  int32_t destCapacity,
796  UErrorCode* ec);
797 
798 
805 U_CAPI void U_EXPORT2
806 unumf_close(UNumberFormatter* uformatter);
807 
808 
815 U_CAPI void U_EXPORT2
817 
818 
819 #if U_SHOW_CPLUSPLUS_API
820 U_NAMESPACE_BEGIN
821 
838 
855 
856 U_NAMESPACE_END
857 #endif // U_SHOW_CPLUSPLUS_API
858 
859 #endif /* #if !UCONFIG_NO_FORMATTING */
860 #endif //__UNUMBERFORMATTER_H__
One more than the highest UNumberSignDisplay value.
C API: Abstract operations for localized strings.
U_CAPI void unumf_formatDouble(const UNumberFormatter *uformatter, double value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a double to a UFormattedNumber.
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
Same as AUTO, but hide trailing zeros after the decimal separator if they are all zero...
One more than the highest UNumberGroupingStrategy value.
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
struct UNumberFormatter UNumberFormatter
C-compatible version of icu::number::LocalizedNumberFormatter.
C API:misc definitions.
struct UFieldPositionIterator UFieldPositionIterator
C typedef for struct UFieldPositionIterator.
Definition: ufieldpositer.h:46
Use the three-digit ISO XXX code in place of the symbol for displaying currencies.
Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive ...
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
U_CAPI int32_t unumf_resultToDecimalNumber(const UFormattedNumber *uresult, char *dest, int32_t destCapacity, UErrorCode *ec)
Extracts the formatted number as a "numeric string" conforming to the syntax defined in the Decimal A...
U_CAPI void unumf_closeResult(UFormattedNumber *uresult)
Releases the UFormattedNumber created by unumf_openResult().
Do not show the sign on positive or negative numbers.
Same as ACCOUNTING, but do not show the sign on negative zero.
Favor adherence to all rounding constraints by producing lower precision.
Format the number according to the specified unit, but do not display the unit.
UNumberTrailingZeroDisplay
An enum declaring how to render trailing zeros.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
U_CAPI void unumf_close(UNumberFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
A struct representing a range of text containing a specific field.
Definition: umisc.h:34
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
UNumberGroupingStrategy
An enum declaring the strategy for when and how to display grouping separators (i.e., the separator, often a comma or period, after every 2-3 powers of ten).
U_CAPI UNumberFormatter * unumf_openForSkeletonAndLocale(const UChar *skeleton, int32_t skeletonLen, const char *locale, UErrorCode *ec)
Creates a new UNumberFormatter for the given skeleton string and locale.
U_CAPI UBool unumf_resultNextFieldPosition(const UFormattedNumber *uresult, UFieldPosition *ufpos, UErrorCode *ec)
Determines the start and end indices of the next occurrence of the given field in the output string...
Show the decimal separator when there are one or more digits to display after the separator...
Same as AUTO, but do not show the sign on negative zero.
Print the full name of the unit, without any abbreviations.
Do not display grouping separators in any locale.
Print an abbreviated version of the unit name.
U_CAPI void unumf_formatDecimal(const UNumberFormatter *uformatter, const char *value, int32_t valueLen, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a decimal number to a UFormattedNumber.
"Smart pointer" class; closes a UFormattedNumber via unumf_closeResult().
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:418
Print an abbreviated version of the unit name.
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
Show the minus sign on negative numbers, and do not show the sign on positive numbers.
C API: Parse Error Information.
Always display the grouping separator on values of at least 1000.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
Use the formal variant of the currency symbol; for example, "NT$" for the New Taiwan dollar in zh-TW...
Show the minus sign on negative numbers and the plus sign on positive numbers, including zero...
C API: UFieldPositionIterator for use with format APIs.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
Display grouping using the default strategy for all locales.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
Basic definitions for ICU, for both C and C++ APIs.
U_CAPI void unumf_resultGetAllFieldPositions(const UFormattedNumber *uresult, UFieldPositionIterator *ufpositer, UErrorCode *ec)
Populates the given iterator with all fields in the formatted output string.
U_CAPI int32_t unumf_resultToString(const UFormattedNumber *uresult, UChar *buffer, int32_t bufferCapacity, UErrorCode *ec)
Extracts the result number string out of a UFormattedNumber to a UChar buffer if possible.
Use the alternate variant of the currency symbol; for example, "TL" for the Turkish lira (TRY)...
U_CAPI const UFormattedValue * unumf_resultAsValue(const UFormattedNumber *uresult, UErrorCode *ec)
Returns a representation of a UFormattedNumber as a UFormattedValue, which can be subsequently passed...
Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater.
Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (suc...
Always show the decimal separator, even if there are no digits to display after the separator...
Show the minus sign on negative numbers and the plus sign on positive numbers.
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Favor greater precision by relaxing one of the rounding constraints.
One more than the highest UNumberDecimalSeparatorDisplay value.
U_CAPI void unumf_formatInt(const UNumberFormatter *uformatter, int64_t value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format an integer to a UFormattedNumber.
Display trailing zeros according to the settings for minimum fraction and significant digits...
One more than the highest UNumberUnitWidth value.
U_CAPI UFormattedNumber * unumf_openResult(UErrorCode *ec)
Creates an object to hold the result of a UNumberFormatter operation.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
UNumberRoundingPriority
An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant di...
U_CAPI UNumberFormatter * unumf_openForSkeletonAndLocaleWithError(const UChar *skeleton, int32_t skeletonLen, const char *locale, UParseError *perror, UErrorCode *ec)
Like unumf_openForSkeletonAndLocale, but accepts a UParseError, which will be populated with the loca...