ICU 76.1 76.1
Loading...
Searching...
No Matches
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"
14
15
133
152typedef 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
264typedef 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
418
419struct UNumberFormatter;
428
429
450U_CAPI UNumberFormatter* U_EXPORT2
451unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
452 UErrorCode* ec);
453
454
470U_CAPI UNumberFormatter* U_EXPORT2
472 const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
473
474
475
491U_CAPI void U_EXPORT2
492unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
493 UErrorCode* ec);
494
495
511U_CAPI void U_EXPORT2
512unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
513 UErrorCode* ec);
514
515
535U_CAPI void U_EXPORT2
536unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
537 UFormattedNumber* uresult, UErrorCode* ec);
538
539
540
547U_CAPI void U_EXPORT2
549
550
551
552#if U_SHOW_CPLUSPLUS_API
553U_NAMESPACE_BEGIN
554
571
572U_NAMESPACE_END
573#endif // U_SHOW_CPLUSPLUS_API
574
575#endif /* #if !UCONFIG_NO_FORMATTING */
576#endif //__UNUMBERFORMATTER_H__
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
C API: Parse Error Information.
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
C API: Formatted number result from various number formatting functions.
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
UNumberRoundingPriority
An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant di...
@ UNUM_ROUNDING_PRIORITY_RELAXED
Favor greater precision by relaxing one of the rounding constraints.
@ UNUM_ROUNDING_PRIORITY_STRICT
Favor adherence to all rounding constraints by producing lower precision.
UNumberSignDisplay
An enum declaring how to denote positive and negative numbers.
@ UNUM_SIGN_ALWAYS
Show the minus sign on negative numbers and the plus sign on positive numbers, including zero.
@ UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
@ UNUM_SIGN_ACCOUNTING_NEGATIVE
Same as ACCOUNTING, but do not show the sign on negative zero.
@ UNUM_SIGN_AUTO
Show the minus sign on negative numbers, and do not show the sign on positive numbers.
@ UNUM_SIGN_ACCOUNTING
Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive ...
@ UNUM_SIGN_NEVER
Do not show the sign on positive or negative numbers.
@ UNUM_SIGN_ACCOUNTING_ALWAYS
Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive nu...
@ UNUM_SIGN_EXCEPT_ZERO
Show the minus sign on negative numbers and the plus sign on positive numbers.
@ UNUM_SIGN_NEGATIVE
Same as AUTO, but do not show the sign on negative zero.
@ UNUM_SIGN_COUNT
One more than the highest UNumberSignDisplay value.
UNumberDecimalSeparatorDisplay
An enum declaring how to render the decimal separator.
@ UNUM_DECIMAL_SEPARATOR_COUNT
One more than the highest UNumberDecimalSeparatorDisplay value.
@ UNUM_DECIMAL_SEPARATOR_AUTO
Show the decimal separator when there are one or more digits to display after the separator,...
@ UNUM_DECIMAL_SEPARATOR_ALWAYS
Always show the decimal separator, even if there are no digits to display after the separator.
UNumberTrailingZeroDisplay
An enum declaring how to render trailing zeros.
@ UNUM_TRAILING_ZERO_AUTO
Display trailing zeros according to the settings for minimum fraction and significant digits.
@ UNUM_TRAILING_ZERO_HIDE_IF_WHOLE
Same as AUTO, but hide trailing zeros after the decimal separator if they are all zero.
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 void unumf_formatDouble(const UNumberFormatter *uformatter, double value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a double to a UFormattedNumber.
UNumberUnitWidth
An enum declaring how to render units, including currencies.
@ UNUM_UNIT_WIDTH_HIDDEN
Format the number according to the specified unit, but do not display the unit.
@ UNUM_UNIT_WIDTH_FULL_NAME
Print the full name of the unit, without any abbreviations.
@ UNUM_UNIT_WIDTH_FORMAL
Use the formal variant of the currency symbol; for example, "NT$" for the New Taiwan dollar in zh-TW.
@ UNUM_UNIT_WIDTH_NARROW
Print an abbreviated version of the unit name.
@ UNUM_UNIT_WIDTH_VARIANT
Use the alternate variant of the currency symbol; for example, "TL" for the Turkish lira (TRY).
@ UNUM_UNIT_WIDTH_ISO_CODE
Use the three-digit ISO XXX code in place of the symbol for displaying currencies.
@ UNUM_UNIT_WIDTH_SHORT
Print an abbreviated version of the unit name.
@ UNUM_UNIT_WIDTH_COUNT
One more than the highest UNumberUnitWidth value.
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.
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.
struct UNumberFormatter UNumberFormatter
C-compatible version of icu::number::LocalizedNumberFormatter.
U_CAPI void unumf_close(UNumberFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
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...
C API: Header-only input options for various number formatting APIs.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430