ICU 67.1  67.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 #include "unicode/utypes.h"
5 
6 #if !UCONFIG_NO_FORMATTING
7 #ifndef __UNUMBERFORMATTER_H__
8 #define __UNUMBERFORMATTER_H__
9 
10 #include "unicode/parseerr.h"
11 #include "unicode/ufieldpositer.h"
12 #include "unicode/umisc.h"
14 
15 
98 typedef enum UNumberUnitWidth {
111 
127 
138 
149 
158 
166 
200 
216 
231 
247 
255 
256 #ifndef U_HIDE_INTERNAL_API
257  ,
264 #endif /* U_HIDE_INTERNAL_API */
265 
267 
287 typedef enum UNumberSignDisplay {
295 
303 
310 
326 
336 
344 
353 
361 
381 
388 
396 
397 struct UNumberFormatter;
406 
407 struct UFormattedNumber;
416 
417 
435 U_STABLE UNumberFormatter* U_EXPORT2
436 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
437  UErrorCode* ec);
438 
439 
452 U_STABLE UNumberFormatter* U_EXPORT2
454  const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
455 
456 
465 U_STABLE UFormattedNumber* U_EXPORT2
467 
468 
484 U_STABLE void U_EXPORT2
485 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
486  UErrorCode* ec);
487 
488 
504 U_STABLE void U_EXPORT2
505 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
506  UErrorCode* ec);
507 
508 
528 U_STABLE void U_EXPORT2
529 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
530  UFormattedNumber* uresult, UErrorCode* ec);
531 
546 U_STABLE const UFormattedValue* U_EXPORT2
547 unumf_resultAsValue(const UFormattedNumber* uresult, UErrorCode* ec);
548 
549 
569 U_STABLE int32_t U_EXPORT2
570 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
571  UErrorCode* ec);
572 
573 
607 U_STABLE UBool U_EXPORT2
609 
610 
632 U_STABLE void U_EXPORT2
634  UErrorCode* ec);
635 
636 
637 // TODO(ICU-20775): Propose this as API.
638 // NOTE: This is not currently implemented.
639 // U_DRAFT int32_t U_EXPORT2
640 // unumf_resultToDecimalNumber(const UFormattedNumber* uresult, char* buffer, int32_t bufferCapacity,
641 // UErrorCode* ec);
642 
643 
650 U_STABLE void U_EXPORT2
651 unumf_close(UNumberFormatter* uformatter);
652 
653 
660 U_STABLE void U_EXPORT2
662 
663 
664 #if U_SHOW_CPLUSPLUS_API
665 U_NAMESPACE_BEGIN
666 
683 
700 
701 U_NAMESPACE_END
702 #endif // U_SHOW_CPLUSPLUS_API
703 
704 #endif //__UNUMBERFORMATTER_H__
705 #endif /* #if !UCONFIG_NO_FORMATTING */
One more than the highest UNumberSignDisplay value.
C API: Abstract operations for localized strings.
const UFormattedValue * unumf_resultAsValue(const UFormattedNumber *uresult, UErrorCode *ec)
Returns a representation of a UFormattedNumber as a UFormattedValue, which can be subsequently passed...
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...
One more than the highest UNumberGroupingStrategy value.
UFormattedNumber * unumf_openResult(UErrorCode *ec)
Creates an object to hold the result of a UNumberFormatter operation.
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:44
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.
void unumf_close(UNumberFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
void unumf_formatDouble(const UNumberFormatter *uformatter, double value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format a double to a UFormattedNumber.
Do not show the sign on positive or negative numbers.
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.
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...
Format the number according to the specified unit, but do not display the unit.
#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.
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).
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.
Show the decimal separator when there are one or more digits to display after the separator...
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.
"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:376
Print an abbreviated version of the unit name.
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
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.
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...
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.
void unumf_formatInt(const UNumberFormatter *uformatter, int64_t value, UFormattedNumber *uresult, UErrorCode *ec)
Uses a UNumberFormatter to format an integer to a UFormattedNumber.
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.
One more than the highest UNumberDecimalSeparatorDisplay value.
void unumf_closeResult(UFormattedNumber *uresult)
Releases the UFormattedNumber created by unumf_openResult().
One more than the highest UNumberUnitWidth value.
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
void unumf_resultGetAllFieldPositions(const UFormattedNumber *uresult, UFieldPositionIterator *ufpositer, UErrorCode *ec)
Populates the given iterator with all fields in the formatted output string.