ICU 74.2  74.2
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/unumberoptions.h"
14 
15 
125 
133 
152 typedef enum UNumberUnitWidth {
165 
181 
192 
203 
214 
225 
234 
235  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
236  // needed for unconditionalized struct MacroProps
244 
264 typedef enum UNumberSignDisplay {
275 
283 
290 
306 
316 
324 
333 
340 
347 
348  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
349  // needed for unconditionalized struct MacroProps
357 
377 
384 
385  // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
386  // needed for unconditionalized struct MacroProps
394 
410 
418 
419 struct UNumberFormatter;
428 
429 
450 U_CAPI UNumberFormatter* U_EXPORT2
451 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
452  UErrorCode* ec);
453 
454 
470 U_CAPI UNumberFormatter* U_EXPORT2
472  const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
473 
474 
475 
491 U_CAPI void U_EXPORT2
492 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
493  UErrorCode* ec);
494 
495 
511 U_CAPI void U_EXPORT2
512 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
513  UErrorCode* ec);
514 
515 
535 U_CAPI void U_EXPORT2
536 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
537  UFormattedNumber* uresult, UErrorCode* ec);
538 
539 
540 
547 U_CAPI void U_EXPORT2
548 unumf_close(UNumberFormatter* uformatter);
549 
550 
551 
552 #if U_SHOW_CPLUSPLUS_API
553 U_NAMESPACE_BEGIN
554 
571 
572 U_NAMESPACE_END
573 #endif // U_SHOW_CPLUSPLUS_API
574 
575 #endif /* #if !UCONFIG_NO_FORMATTING */
576 #endif //__UNUMBERFORMATTER_H__
One more than the highest UNumberSignDisplay value.
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...
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.
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.
C API: Header-only input options for various number formatting APIs.
Do not show the sign on positive or negative numbers.
C API: Formatted number result from various number formatting functions.
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
U_CAPI void unumf_close(UNumberFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
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.
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.
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.
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:386
Print an abbreviated version of the unit name.
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
Show the minus sign on negative numbers, and do not show the sign on positive numbers.
C API: Parse Error Information.
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...
UNumberUnitWidth
An enum declaring how to render units, including currencies.
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.
Use the alternate variant of the currency symbol; for example, "TL" for the Turkish lira (TRY)...
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.
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.
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...