summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/unicode
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/unicode')
-rw-r--r--deps/icu-small/source/i18n/unicode/compactdecimalformat.h10
-rw-r--r--deps/icu-small/source/i18n/unicode/datefmt.h3
-rw-r--r--deps/icu-small/source/i18n/unicode/dcfmtsym.h67
-rw-r--r--deps/icu-small/source/i18n/unicode/decimfmt.h27
-rw-r--r--deps/icu-small/source/i18n/unicode/dtptngen.h30
-rw-r--r--deps/icu-small/source/i18n/unicode/measfmt.h19
-rw-r--r--deps/icu-small/source/i18n/unicode/measunit.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/nounit.h10
-rw-r--r--deps/icu-small/source/i18n/unicode/numberformatter.h418
-rw-r--r--deps/icu-small/source/i18n/unicode/numfmt.h37
-rw-r--r--deps/icu-small/source/i18n/unicode/simpletz.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/udatpg.h53
-rw-r--r--deps/icu-small/source/i18n/unicode/unum.h9
-rw-r--r--deps/icu-small/source/i18n/unicode/upluralrules.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/utrans.h4
15 files changed, 549 insertions, 158 deletions
diff --git a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
index 3fbe5da9ce..d682d2d0e7 100644
--- a/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
+++ b/deps/icu-small/source/i18n/unicode/compactdecimalformat.h
@@ -16,7 +16,7 @@
#include "unicode/utypes.h"
/**
* \file
- * \brief C++ API: Formats decimal numbers in compact form.
+ * \brief C++ API: Compatibility APIs for compact decimal number formatting.
*/
#if !UCONFIG_NO_FORMATTING
@@ -30,6 +30,11 @@ U_NAMESPACE_BEGIN
class PluralRules;
/**
+ * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if
+ * numberformatter.h fits their use case. Although not deprecated, this header
+ * is provided for backwards compatibility only.
+ * <hr/>
+ *
* The CompactDecimalFormat produces abbreviated numbers, suitable for display in
* environments will limited real estate. For example, 'Hits: 1.2B' instead of
* 'Hits: 1,200,000,000'. The format will be appropriate for the given language,
@@ -56,6 +61,9 @@ public:
/**
* Returns a compact decimal instance for specified locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @param style whether to use short or long style.
* @param status error code returned here.
diff --git a/deps/icu-small/source/i18n/unicode/datefmt.h b/deps/icu-small/source/i18n/unicode/datefmt.h
index d70d8d1dd5..c895183931 100644
--- a/deps/icu-small/source/i18n/unicode/datefmt.h
+++ b/deps/icu-small/source/i18n/unicode/datefmt.h
@@ -44,7 +44,8 @@ class TimeZone;
class DateTimePatternGenerator;
// explicit template instantiation. see digitlst.h
-#if defined (_MSC_VER)
+// (When building DLLs for Windows this is required.)
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
template class U_I18N_API EnumSet<UDateFormatBooleanAttribute,
0,
UDAT_BOOLEAN_ATTRIBUTE_COUNT>;
diff --git a/deps/icu-small/source/i18n/unicode/dcfmtsym.h b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
index 4dc6f950f2..e58befa31b 100644
--- a/deps/icu-small/source/i18n/unicode/dcfmtsym.h
+++ b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
@@ -80,10 +80,6 @@ U_NAMESPACE_BEGIN
* If you supply a pattern with multiple grouping characters, the interval
* between the last one and the end of the integer is the one that is
* used. So "#,##,###,####" == "######,####" == "##,####,####".
- * <P>
- * This class only handles localized digits where the 10 digits are
- * contiguous in Unicode, from 0 to 9. Other digits sets (such as
- * superscripts) would need a different subclass.
*/
class U_I18N_API DecimalFormatSymbols : public UObject {
public:
@@ -396,6 +392,13 @@ public:
inline UBool isCustomIntlCurrencySymbol() const {
return fIsCustomIntlCurrencySymbol;
}
+
+ /**
+ * @internal For ICU use only
+ */
+ inline UChar32 getCodePointZero() const {
+ return fCodePointZero;
+ }
#endif /* U_HIDE_INTERNAL_API */
/**
@@ -410,10 +413,23 @@ public:
* @return the format symbol by the param 'symbol'
* @internal
*/
- inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
+ inline const UnicodeString& getConstSymbol(ENumberFormatSymbol symbol) const;
#ifndef U_HIDE_INTERNAL_API
/**
+ * Returns the const UnicodeString reference, like getConstSymbol,
+ * corresponding to the digit with the given value. This is equivalent
+ * to accessing the symbol from getConstSymbol with the corresponding
+ * key, such as kZeroDigitSymbol or kOneDigitSymbol.
+ *
+ * @param digit The digit, an integer between 0 and 9 inclusive.
+ * If outside the range 0 to 9, the zero digit is returned.
+ * @return the format symbol for the given digit.
+ * @internal This API is currently for ICU use only.
+ */
+ inline const UnicodeString& getConstDigitSymbol(int32_t digit) const;
+
+ /**
* Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
* @internal
*/
@@ -444,6 +460,22 @@ private:
*/
UnicodeString fNoSymbol;
+ /**
+ * Dealing with code points is faster than dealing with strings when formatting. Because of
+ * this, we maintain a value containing the zero code point that is used whenever digitStrings
+ * represents a sequence of ten code points in order.
+ *
+ * <p>If the value stored here is positive, it means that the code point stored in this value
+ * corresponds to the digitStrings array, and codePointZero can be used instead of the
+ * digitStrings array for the purposes of efficient formatting; if -1, then digitStrings does
+ * *not* contain a sequence of code points, and it must be used directly.
+ *
+ * <p>It is assumed that codePointZero always shadows the value in digitStrings. codePointZero
+ * should never be set directly; rather, it should be updated only when digitStrings mutates.
+ * That is, the flow of information is digitStrings -> codePointZero, not the other way.
+ */
+ UChar32 fCodePointZero;
+
Locale locale;
char actualLocale[ULOC_FULLNAME_CAPACITY];
@@ -469,7 +501,7 @@ DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
return *strPtr;
}
-// See comments above for this function. Not hidden with #ifndef U_HIDE_INTERNAL_API
+// See comments above for this function. Not hidden with #ifdef U_HIDE_INTERNAL_API
inline const UnicodeString &
DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
const UnicodeString *strPtr;
@@ -481,6 +513,19 @@ DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
return *strPtr;
}
+#ifndef U_HIDE_INTERNAL_API
+inline const UnicodeString& DecimalFormatSymbols::getConstDigitSymbol(int32_t digit) const {
+ if (digit < 0 || digit > 9) {
+ digit = 0;
+ }
+ if (digit == 0) {
+ return fSymbols[kZeroDigitSymbol];
+ }
+ ENumberFormatSymbol key = static_cast<ENumberFormatSymbol>(kOneDigitSymbol + digit - 1);
+ return fSymbols[key];
+}
+#endif
+
// -------------------------------------
inline void
@@ -497,14 +542,20 @@ DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString
// If the zero digit is being set to a known zero digit according to Unicode,
// then we automatically set the corresponding 1-9 digits
- if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) {
+ // Also record updates to fCodePointZero. Be conservative if in doubt.
+ if (symbol == kZeroDigitSymbol) {
UChar32 sym = value.char32At(0);
- if ( u_charDigitValue(sym) == 0 ) {
+ if ( propogateDigits && u_charDigitValue(sym) == 0 && value.countChar32() == 1 ) {
+ fCodePointZero = sym;
for ( int8_t i = 1 ; i<= 9 ; i++ ) {
sym++;
fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym);
}
+ } else {
+ fCodePointZero = -1;
}
+ } else if (symbol >= kOneDigitSymbol && symbol <= kNineDigitSymbol) {
+ fCodePointZero = -1;
}
}
diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h
index 790053636d..b062208d9b 100644
--- a/deps/icu-small/source/i18n/unicode/decimfmt.h
+++ b/deps/icu-small/source/i18n/unicode/decimfmt.h
@@ -30,7 +30,7 @@
#include "unicode/utypes.h"
/**
* \file
- * \brief C++ API: Formats decimal numbers.
+ * \brief C++ API: Compatibility APIs for decimal formatting.
*/
#if !UCONFIG_NO_FORMATTING
@@ -67,13 +67,19 @@ class PluralRules;
class VisibleDigitsWithExponent;
// explicit template instantiation. see digitlst.h
-#if defined (_MSC_VER)
+// (When building DLLs for Windows this is required.)
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
template class U_I18N_API EnumSet<UNumberFormatAttribute,
UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
#endif
/**
+ * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if
+ * numberformatter.h fits their use case. Although not deprecated, this header
+ * is provided for backwards compatibility only.
+ * <hr/>
+ *
* DecimalFormat is a concrete subclass of NumberFormat that formats decimal
* numbers. It has a variety of features designed to make it possible to parse
* and format numbers in any locale, including support for Western, Arabic, or
@@ -688,6 +694,9 @@ public:
* on NumberFormat such as createInstance. These factories will
* return the most appropriate sub-class of NumberFormat for a given
* locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of DecimalFormat.
* @param status Output param set to success/failure code. If the
* pattern is invalid this will be set to a failure code.
* @stable ICU 2.0
@@ -703,6 +712,9 @@ public:
* on NumberFormat such as createInstance. These factories will
* return the most appropriate sub-class of NumberFormat for a given
* locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of DecimalFormat.
* @param pattern A non-localized pattern string.
* @param status Output param set to success/failure code. If the
* pattern is invalid this will be set to a failure code.
@@ -721,6 +733,9 @@ public:
* createInstance or createCurrencyInstance. If you need only minor adjustments
* to a standard format, you can modify the format returned by
* a NumberFormat factory method.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of DecimalFormat.
*
* @param pattern a non-localized pattern string
* @param symbolsToAdopt the set of symbols to be used. The caller should not
@@ -826,6 +841,9 @@ public:
* createInstance or createCurrencyInstance. If you need only minor adjustments
* to a standard format, you can modify the format returned by
* a NumberFormat factory method.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of DecimalFormat.
*
* @param pattern a non-localized pattern string
* @param symbolsToAdopt the set of symbols to be used. The caller should not
@@ -849,6 +867,9 @@ public:
* createInstance or createCurrencyInstance. If you need only minor adjustments
* to a standard format, you can modify the format returned by
* a NumberFormat factory method.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of DecimalFormat.
*
* @param pattern a non-localized pattern string
* @param symbols the set of symbols to be used
@@ -1964,12 +1985,14 @@ public:
UCurrencyUsage getCurrencyUsage() const;
+#ifndef U_HIDE_DEPRECATED_API
/**
* The resource tags we use to retrieve decimal format data from
* locale resource bundles.
* @deprecated ICU 3.4. This string has no public purpose. Please don't use it.
*/
static const char fgNumberPatterns[];
+#endif // U_HIDE_DEPRECATED_API
#ifndef U_HIDE_INTERNAL_API
/**
diff --git a/deps/icu-small/source/i18n/unicode/dtptngen.h b/deps/icu-small/source/i18n/unicode/dtptngen.h
index 5712edbb9f..feb465e799 100644
--- a/deps/icu-small/source/i18n/unicode/dtptngen.h
+++ b/deps/icu-small/source/i18n/unicode/dtptngen.h
@@ -263,14 +263,29 @@ public:
/**
* Getter corresponding to setAppendItemNames. Values below 0 or at or above
- * UDATPG_FIELD_COUNT are illegal arguments.
+ * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method
+ * for getting date/time field display names is getFieldDisplayName.
*
* @param field such as UDATPG_ERA_FIELD.
* @return name for field
+ * @see getFieldDisplayName
* @stable ICU 3.8
*/
const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * The general interface to get a display name for a particular date/time field,
+ * in one of several possible display widths.
+ *
+ * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
+ * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
+ * @return. The display name for field
+ * @draft ICU 61
+ */
+ UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const;
+#endif // U_HIDE_DRAFT_API
+
/**
* The DateTimeFormat is a message format pattern used to compose date and
* time patterns. The default pattern in the root locale is "{1} {0}", where
@@ -507,13 +522,17 @@ private:
*/
DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
+ // TODO(ticket:13619): re-enable when UDATPG_NARROW no longer in draft mode.
+ // static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1;
+
Locale pLocale; // pattern locale
FormatParser *fp;
DateTimeMatcher* dtMatcher;
DistanceInfo *distanceInfo;
PatternMap *patternMap;
UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
- UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
+ // TODO(ticket:13619): [3] -> UDATPG_WIDTH_COUNT
+ UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][3];
UnicodeString dateTimeFormat;
UnicodeString decimal;
DateTimeMatcher *skipMatcher;
@@ -543,8 +562,11 @@ private:
void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
void setDecimalSymbols(const Locale& locale, UErrorCode& status);
UDateTimePatternField getAppendFormatNumber(const char* field) const;
- UDateTimePatternField getAppendNameNumber(const char* field) const;
- UnicodeString& getMutableAppendItemName(UDateTimePatternField field);
+#ifndef U_HIDE_DRAFT_API
+ UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const;
+ void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value);
+ UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width);
+#endif // U_HIDE_DRAFT_API
void getAppendName(UDateTimePatternField field, UnicodeString& value);
UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status);
int32_t getCanonicalIndex(const UnicodeString& field);
diff --git a/deps/icu-small/source/i18n/unicode/measfmt.h b/deps/icu-small/source/i18n/unicode/measfmt.h
index 251fd213b5..14399dd59a 100644
--- a/deps/icu-small/source/i18n/unicode/measfmt.h
+++ b/deps/icu-small/source/i18n/unicode/measfmt.h
@@ -22,7 +22,7 @@
/**
* \file
- * \brief C++ API: Formatter for measure objects.
+ * \brief C++ API: Compatibility APIs for measure formatting.
*/
/**
@@ -87,8 +87,9 @@ class ListFormatter;
class DateFormat;
/**
- *
- * A formatter for measure objects.
+ * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if
+ * numberformatter.h fits their use case. Although not deprecated, this header
+ * is provided for backwards compatibility only.
*
* @see Format
* @author Alan Liu
@@ -101,6 +102,9 @@ class U_I18N_API MeasureFormat : public Format {
/**
* Constructor.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 53
*/
MeasureFormat(
@@ -108,6 +112,9 @@ class U_I18N_API MeasureFormat : public Format {
/**
* Constructor.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 53
*/
MeasureFormat(
@@ -227,6 +234,9 @@ class U_I18N_API MeasureFormat : public Format {
/**
* Return a formatter for CurrencyAmount objects in the given
* locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param locale desired locale
* @param ec input-output error code
* @return a formatter object, or NULL upon error
@@ -238,6 +248,9 @@ class U_I18N_API MeasureFormat : public Format {
/**
* Return a formatter for CurrencyAmount objects in the default
* locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param ec input-output error code
* @return a formatter object, or NULL upon error
* @stable ICU 3.0
diff --git a/deps/icu-small/source/i18n/unicode/measunit.h b/deps/icu-small/source/i18n/unicode/measunit.h
index 08c8d6f588..f7ddb4e20c 100644
--- a/deps/icu-small/source/i18n/unicode/measunit.h
+++ b/deps/icu-small/source/i18n/unicode/measunit.h
@@ -196,8 +196,8 @@ class U_I18N_API MeasureUnit: public UObject {
* ICU use only.
* @internal
*/
- static MeasureUnit *resolveUnitPerUnit(
- const MeasureUnit &unit, const MeasureUnit &perUnit);
+ static MeasureUnit resolveUnitPerUnit(
+ const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved);
#endif /* U_HIDE_INTERNAL_API */
// All code between the "Start generated createXXX methods" comment and
@@ -832,15 +832,13 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createPicometer(UErrorCode &status);
-#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of length: point.
* Caller owns returned value and must free it.
* @param status ICU error code.
- * @draft ICU 59
+ * @stable ICU 59
*/
static MeasureUnit *createPoint(UErrorCode &status);
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of length: yard.
diff --git a/deps/icu-small/source/i18n/unicode/nounit.h b/deps/icu-small/source/i18n/unicode/nounit.h
index 04fc84b33a..290e77e880 100644
--- a/deps/icu-small/source/i18n/unicode/nounit.h
+++ b/deps/icu-small/source/i18n/unicode/nounit.h
@@ -10,17 +10,17 @@
#ifndef __NOUNIT_H__
#define __NOUNIT_H__
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measunit.h"
/**
* \file
* \brief C++ API: units for percent and permille
*/
-
-#include "unicode/measunit.h"
-
-#if !UCONFIG_NO_FORMATTING
-
U_NAMESPACE_BEGIN
#ifndef U_HIDE_DRAFT_API
diff --git a/deps/icu-small/source/i18n/unicode/numberformatter.h b/deps/icu-small/source/i18n/unicode/numberformatter.h
index 4a11c2f915..3fbb33ccee 100644
--- a/deps/icu-small/source/i18n/unicode/numberformatter.h
+++ b/deps/icu-small/source/i18n/unicode/numberformatter.h
@@ -88,10 +88,6 @@
* </ul>
*
* <p>
- * * The narrow format for currencies is not currently supported; this is a known issue that will be fixed in a
- * future version. See #11666 for more information.
- *
- * <p>
* This enum is similar to {@link com.ibm.icu.text.MeasureFormat.FormatWidth}.
*
* @draft ICU 60
@@ -155,27 +151,122 @@ typedef enum UNumberUnitWidth {
*
* @draft ICU 60
*/
- UNUM_UNIT_WIDTH_HIDDEN,
+ UNUM_UNIT_WIDTH_HIDDEN
+#ifndef U_HIDE_INTERNAL_API
+ ,
/**
* One more than the highest UNumberUnitWidth value.
*
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
*/
UNUM_UNIT_WIDTH_COUNT
+#endif // U_HIDE_INTERNAL_API
} UNumberUnitWidth;
/**
- * An enum declaring how to denote positive and negative numbers. Example outputs when formatting 123 and -123 in
- * <em>en-US</em>:
+ * 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). The choices are several
+ * pre-built strategies for different use cases that employ locale data whenever possible. Example
+ * outputs for 1234 and 1234567 in <em>en-IN</em>:
+ *
+ * <ul>
+ * <li>OFF: 1234 and 12345
+ * <li>MIN2: 1234 and 12,34,567
+ * <li>AUTO: 1,234 and 12,34,567
+ * <li>ON_ALIGNED: 1,234 and 12,34,567
+ * <li>THOUSANDS: 1,234 and 1,234,567
+ * </ul>
*
* <p>
+ * The default is AUTO, which displays grouping separators unless the locale data says that grouping
+ * is not customary. To force grouping for all numbers greater than 1000 consistently across locales,
+ * use ON_ALIGNED. On the other hand, to display grouping less frequently than the default, use MIN2
+ * or OFF. See the docs of each option for details.
+ *
+ * <p>
+ * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the
+ * grouping separator, use the "symbols" setter.
+ *
+ * @draft ICU 61
+ */
+typedef enum UGroupingStrategy {
+ /**
+ * Do not display grouping separators in any locale.
+ *
+ * @draft ICU 61
+ */
+ UNUM_GROUPING_OFF,
+
+ /**
+ * Display grouping using locale defaults, except do not show grouping on values smaller than
+ * 10000 (such that there is a <em>minimum of two digits</em> before the first separator).
+ *
+ * <p>
+ * Note that locales may restrict grouping separators to be displayed only on 1 million or
+ * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
+ *
+ * <p>
+ * Locale data is used to determine whether to separate larger numbers into groups of 2
+ * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
+ *
+ * @draft ICU 61
+ */
+ UNUM_GROUPING_MIN2,
+
+ /**
+ * Display grouping using the default strategy for all locales. This is the default behavior.
+ *
+ * <p>
+ * Note that locales may restrict grouping separators to be displayed only on 1 million or
+ * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
+ *
+ * <p>
+ * Locale data is used to determine whether to separate larger numbers into groups of 2
+ * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
+ *
+ * @draft ICU 61
+ */
+ UNUM_GROUPING_AUTO,
+
+ /**
+ * Always display the grouping separator on values of at least 1000.
+ *
+ * <p>
+ * This option ignores the locale data that restricts or disables grouping, described in MIN2 and
+ * AUTO. This option may be useful to normalize the alignment of numbers, such as in a
+ * spreadsheet.
+ *
+ * <p>
+ * Locale data is used to determine whether to separate larger numbers into groups of 2
+ * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
+ *
+ * @draft ICU 61
+ */
+ UNUM_GROUPING_ON_ALIGNED,
+
+ /**
+ * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use
+ * locale data for determining the grouping strategy.
+ *
+ * @draft ICU 61
+ */
+ UNUM_GROUPING_THOUSANDS
+
+} UGroupingStrategy;
+
+/**
+ * An enum declaring how to denote positive and negative numbers. Example outputs when formatting
+ * 123, 0, and -123 in <em>en-US</em>:
+ *
* <ul>
- * <li>AUTO: "123", "-123"
- * <li>ALWAYS: "+123", "-123"
- * <li>NEVER: "123", "123"
- * <li>ACCOUNTING: "$123", "($123)"
- * <li>ACCOUNTING_ALWAYS: "+$123", "($123)"
+ * <li>AUTO: "123", "0", and "-123"
+ * <li>ALWAYS: "+123", "+0", and "-123"
+ * <li>NEVER: "123", "0", and "123"
+ * <li>ACCOUNTING: "$123", "$0", and "($123)"
+ * <li>ACCOUNTING_ALWAYS: "+$123", "+$0", and "($123)"
+ * <li>EXCEPT_ZERO: "+123", "0", and "-123"
+ * <li>ACCOUNTING_EXCEPT_ZERO: "+$123", "$0", and "($123)"
* </ul>
*
* <p>
@@ -190,21 +281,22 @@ typedef enum UNumberSignDisplay {
*
* @draft ICU 60
*/
- UNUM_SIGN_AUTO,
+ UNUM_SIGN_AUTO,
/**
- * Show the minus sign on negative numbers and the plus sign on positive numbers.
+ * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero.
+ * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}.
*
* @draft ICU 60
*/
- UNUM_SIGN_ALWAYS,
+ UNUM_SIGN_ALWAYS,
/**
* Do not show the sign on positive or negative numbers.
*
* @draft ICU 60
*/
- UNUM_SIGN_NEVER,
+ UNUM_SIGN_NEVER,
/**
* Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers.
@@ -220,22 +312,44 @@ typedef enum UNumberSignDisplay {
*
* @draft ICU 60
*/
- UNUM_SIGN_ACCOUNTING,
+ UNUM_SIGN_ACCOUNTING,
/**
- * Use the locale-dependent accounting format on negative numbers, and show the plus sign on positive numbers.
- * For more information on the accounting format, see the ACCOUNTING sign display strategy.
+ * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
+ * positive numbers, including zero. For more information on the accounting format, see the
+ * ACCOUNTING sign display strategy. To hide the sign on zero, see
+ * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}.
*
* @draft ICU 60
*/
- UNUM_SIGN_ACCOUNTING_ALWAYS,
+ UNUM_SIGN_ACCOUNTING_ALWAYS,
+
+ /**
+ * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a
+ * sign on zero.
+ *
+ * @draft ICU 61
+ */
+ UNUM_SIGN_EXCEPT_ZERO,
+
+ /**
+ * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
+ * positive numbers. Do not show a sign on zero. For more information on the accounting format,
+ * see the ACCOUNTING sign display strategy.
+ *
+ * @draft ICU 61
+ */
+ UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO
+#ifndef U_HIDE_INTERNAL_API
+ ,
/**
* One more than the highest UNumberSignDisplay value.
*
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
*/
- UNUM_SIGN_COUNT
+ UNUM_SIGN_COUNT
+#endif // U_HIDE_INTERNAL_API
} UNumberSignDisplay;
/**
@@ -261,14 +375,17 @@ typedef enum UNumberDecimalSeparatorDisplay {
*
* @draft ICU 60
*/
- UNUM_DECIMAL_SEPARATOR_ALWAYS,
+ UNUM_DECIMAL_SEPARATOR_ALWAYS
+#ifndef U_HIDE_INTERNAL_API
+ ,
/**
* One more than the highest UNumberDecimalSeparatorDisplay value.
*
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
*/
UNUM_DECIMAL_SEPARATOR_COUNT
+#endif // U_HIDE_INTERNAL_API
} UNumberDecimalMarkDisplay;
U_NAMESPACE_BEGIN namespace number { // icu::number
@@ -283,11 +400,27 @@ class Rounder;
class FractionRounder;
class CurrencyRounder;
class IncrementRounder;
-class Grouper;
class IntegerWidth;
namespace impl {
+#ifndef U_HIDE_INTERNAL_API
+/**
+ * Datatype for minimum/maximum fraction digits. Must be able to hold kMaxIntFracSig.
+ *
+ * @internal
+ */
+typedef int16_t digits_t;
+
+/**
+ * Use a default threshold of 3. This means that the third time .format() is called, the data structures get built
+ * using the "safe" code path. The first two calls to .format() will trigger the unsafe code path.
+ *
+ * @internal
+ */
+static constexpr int32_t DEFAULT_THRESHOLD = 3;
+#endif // U_HIDE_INTERNAL_API
+
// Forward declarations:
class Padder;
struct MacroProps;
@@ -471,7 +604,7 @@ class U_I18N_API Notation : public UMemory {
struct ScientificSettings {
int8_t fEngineeringInterval;
bool fRequireMinInt;
- int8_t fMinExponentDigits;
+ impl::digits_t fMinExponentDigits;
UNumberSignDisplay fExponentSignDisplay;
} scientific;
@@ -786,14 +919,14 @@ class U_I18N_API Rounder : public UMemory {
union RounderUnion {
struct FractionSignificantSettings {
// For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
- int8_t fMinFrac;
- int8_t fMaxFrac;
- int8_t fMinSig;
- int8_t fMaxSig;
+ impl::digits_t fMinFrac;
+ impl::digits_t fMaxFrac;
+ impl::digits_t fMinSig;
+ impl::digits_t fMaxSig;
} fracSig;
struct IncrementSettings {
double fIncrement;
- int32_t fMinFrac;
+ impl::digits_t fMinFrac;
} increment; // For RND_INCREMENT
UCurrencyUsage currencyUsage; // For RND_CURRENCY
UErrorCode errorCode; // For RND_ERROR
@@ -836,6 +969,20 @@ class U_I18N_API Rounder : public UMemory {
/** Version of {@link #apply} that obeys minInt constraints. Used for scientific notation compatibility mode. */
void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
+ /**
+ * Rounding endpoint used by Engineering and Compact notation. Chooses the most appropriate multiplier (magnitude
+ * adjustment), applies the adjustment, rounds, and returns the chosen multiplier.
+ *
+ * <p>
+ * In most cases, this is simple. However, when rounding the number causes it to cross a multiplier boundary, we
+ * need to re-do the rounding. For example, to display 999,999 in Engineering notation with 2 sigfigs, first you
+ * guess the multiplier to be -3. However, then you end up getting 1000E3, which is not the correct output. You then
+ * change your multiplier to be -6, and you get 1.0E6, which is correct.
+ *
+ * @param input The quantity to process.
+ * @param producer Function to call to return a multiplier based on a magnitude.
+ * @return The number of orders of magnitude the input was adjusted by this method.
+ */
int32_t
chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer,
UErrorCode &status);
@@ -1003,53 +1150,6 @@ class U_I18N_API IncrementRounder : public Rounder {
};
/**
- * @internal This API is a technical preview. It is likely to change in an upcoming release.
- */
-class U_I18N_API Grouper : public UMemory {
- public:
- /**
- * @internal This API is a technical preview. It is likely to change in an upcoming release.
- */
- static Grouper defaults();
-
- /**
- * @internal This API is a technical preview. It is likely to change in an upcoming release.
- */
- static Grouper minTwoDigits();
-
- /**
- * @internal This API is a technical preview. It is likely to change in an upcoming release.
- */
- static Grouper none();
-
- private:
- int8_t fGrouping1; // -3 means "bogus"; -2 means "needs locale data"; -1 means "no grouping"
- int8_t fGrouping2;
- bool fMin2;
-
- Grouper(int8_t grouping1, int8_t grouping2, bool min2)
- : fGrouping1(grouping1), fGrouping2(grouping2), fMin2(min2) {}
-
- Grouper() : fGrouping1(-3) {};
-
- bool isBogus() const {
- return fGrouping1 == -3;
- }
-
- /** NON-CONST: mutates the current instance. */
- void setLocaleData(const impl::ParsedPatternInfo &patternInfo);
-
- bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
-
- // To allow MacroProps/MicroProps to initialize empty instances:
- friend struct impl::MacroProps;
- friend struct impl::MicroProps;
-
- // To allow NumberFormatterImpl to access isBogus() and perform other operations:
- friend class impl::NumberFormatterImpl;
-};
-
-/**
* A class that defines the strategy for padding and truncating integers before the decimal separator.
*
* <p>
@@ -1080,7 +1180,8 @@ class U_I18N_API IntegerWidth : public UMemory {
* For example, with maxInt=3, the number 1234 will get printed as "234".
*
* @param maxInt
- * The maximum number of places before the decimal separator.
+ * The maximum number of places before the decimal separator. maxInt == -1 means no
+ * truncation.
* @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter.
* @draft ICU 60
* @see NumberFormatter
@@ -1090,14 +1191,14 @@ class U_I18N_API IntegerWidth : public UMemory {
private:
union {
struct {
- int8_t fMinInt;
- int8_t fMaxInt;
+ impl::digits_t fMinInt;
+ impl::digits_t fMaxInt;
} minMaxInt;
UErrorCode errorCode;
} fUnion;
bool fHasError = false;
- IntegerWidth(int8_t minInt, int8_t maxInt);
+ IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt);
IntegerWidth(UErrorCode errorCode) { // NOLINT
fUnion.errorCode = errorCode;
@@ -1132,14 +1233,7 @@ class U_I18N_API IntegerWidth : public UMemory {
namespace impl {
-/**
- * Use a default threshold of 3. This means that the third time .format() is called, the data structures get built
- * using the "safe" code path. The first two calls to .format() will trigger the unsafe code path.
- *
- * @internal
- */
-static constexpr int32_t DEFAULT_THRESHOLD = 3;
-
+// Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
/** @internal */
class U_I18N_API SymbolsWrapper : public UMemory {
public:
@@ -1155,6 +1249,7 @@ class U_I18N_API SymbolsWrapper : public UMemory {
/** @internal */
SymbolsWrapper &operator=(const SymbolsWrapper &other);
+#ifndef U_HIDE_INTERNAL_API
/**
* The provided object is copied, but we do not adopt it.
* @internal
@@ -1202,6 +1297,7 @@ class U_I18N_API SymbolsWrapper : public UMemory {
}
return FALSE;
}
+#endif // U_HIDE_INTERNAL_API
private:
enum SymbolsPointerType {
@@ -1218,14 +1314,72 @@ class U_I18N_API SymbolsWrapper : public UMemory {
void doCleanup();
};
+// Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
+/** @internal */
+class U_I18N_API Grouper : public UMemory {
+ public:
+#ifndef U_HIDE_INTERNAL_API
+ /** @internal */
+ static Grouper forStrategy(UGroupingStrategy grouping);
+
+ // Future: static Grouper forProperties(DecimalFormatProperties& properties);
+
+ /** @internal */
+ Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
+ : fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping) {}
+#endif // U_HIDE_INTERNAL_API
+
+ private:
+ /**
+ * The grouping sizes, with the following special values:
+ * <ul>
+ * <li>-1 = no grouping
+ * <li>-2 = needs locale data
+ * <li>-4 = fall back to Western grouping if not in locale
+ * </ul>
+ */
+ int16_t fGrouping1;
+ int16_t fGrouping2;
+
+ /**
+ * The minimum gropuing size, with the following special values:
+ * <ul>
+ * <li>-2 = needs locale data
+ * <li>-3 = no less than 2
+ * </ul>
+ */
+ int16_t fMinGrouping;
+
+ Grouper() : fGrouping1(-3) {};
+
+ bool isBogus() const {
+ return fGrouping1 == -3;
+ }
+
+ /** NON-CONST: mutates the current instance. */
+ void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
+
+ bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
+
+ // To allow MacroProps/MicroProps to initialize empty instances:
+ friend struct MacroProps;
+ friend struct MicroProps;
+
+ // To allow NumberFormatterImpl to access isBogus() and perform other operations:
+ friend class NumberFormatterImpl;
+};
+
+// Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
/** @internal */
class U_I18N_API Padder : public UMemory {
public:
+#ifndef U_HIDE_INTERNAL_API
/** @internal */
static Padder none();
/** @internal */
static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
+#endif // U_HIDE_INTERNAL_API
private:
UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
@@ -1275,6 +1429,7 @@ class U_I18N_API Padder : public UMemory {
friend class impl::NumberFormatterImpl;
};
+// Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
/** @internal */
struct U_I18N_API MacroProps : public UMemory {
/** @internal */
@@ -1284,6 +1439,9 @@ struct U_I18N_API MacroProps : public UMemory {
MeasureUnit unit; // = NoUnit::base();
/** @internal */
+ MeasureUnit perUnit; // = NoUnit::base();
+
+ /** @internal */
Rounder rounder; // = Rounder(); (bogus)
/** @internal */
@@ -1375,29 +1533,30 @@ class U_I18N_API NumberFormatterSettings {
* <li>Percent: "12.3%"
* </ul>
*
- * <p>
* All units will be properly localized with locale data, and all units are compatible with notation styles,
* rounding strategies, and other number formatter settings.
*
- * <p>
- * Pass this method any instance of {@link MeasureUnit}. For units of measure:
+ * Pass this method any instance of {@link MeasureUnit}. For units of measure (which often involve the
+ * factory methods that return a pointer):
*
* <pre>
- * NumberFormatter.with().adoptUnit(MeasureUnit::createMeter(status))
+ * NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
* </pre>
*
* Currency:
*
* <pre>
- * NumberFormatter.with()::unit(CurrencyUnit(u"USD", status))
+ * NumberFormatter::with().unit(CurrencyUnit(u"USD", status))
* </pre>
*
* Percent:
*
* <pre>
- * NumberFormatter.with()::unit(NoUnit.percent())
+ * NumberFormatter::with().unit(NoUnit.percent())
* </pre>
*
+ * See {@link #perUnit} for information on how to format strings like "5 meters per second".
+ *
* The default is to render without units (equivalent to NoUnit.base()).
*
* @param unit
@@ -1406,22 +1565,65 @@ class U_I18N_API NumberFormatterSettings {
* @see MeasureUnit
* @see Currency
* @see NoUnit
+ * @see #perUnit
* @draft ICU 60
*/
Derived unit(const icu::MeasureUnit &unit) const;
/**
* Like unit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
- * methods, which return pointers that need ownership.
+ * methods, which return pointers that need ownership. Example:
+ *
+ * <pre>
+ * NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
+ * </pre>
*
* @param unit
- * The unit to render.
+ * The unit to render.
* @return The fluent chain.
* @see #unit
* @see MeasureUnit
* @draft ICU 60
*/
- Derived adoptUnit(const icu::MeasureUnit *unit) const;
+ Derived adoptUnit(icu::MeasureUnit *unit) const;
+
+ /**
+ * Sets a unit to be used in the denominator. For example, to format "3 m/s", pass METER to the unit and SECOND to
+ * the perUnit.
+ *
+ * Pass this method any instance of {@link MeasureUnit}. Since MeasureUnit factory methods return pointers, the
+ * {@link #adoptPerUnit} version of this method is often more useful.
+ *
+ * The default is not to display any unit in the denominator.
+ *
+ * If a per-unit is specified without a primary unit via {@link #unit}, the behavior is undefined.
+ *
+ * @param perUnit
+ * The unit to render in the denominator.
+ * @return The fluent chain
+ * @see #unit
+ * @draft ICU 61
+ */
+ Derived perUnit(const icu::MeasureUnit &perUnit) const;
+
+ /**
+ * Like perUnit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
+ * methods, which return pointers that need ownership. Example:
+ *
+ * <pre>
+ * NumberFormatter::with()
+ * .adoptUnit(MeasureUnit::createMeter(status))
+ * .adoptPerUnit(MeasureUnit::createSecond(status))
+ * </pre>
+ *
+ * @param perUnit
+ * The unit to render in the denominator.
+ * @return The fluent chain.
+ * @see #perUnit
+ * @see MeasureUnit
+ * @draft ICU 61
+ */
+ Derived adoptPerUnit(icu::MeasureUnit *perUnit) const;
/**
* Specifies the rounding strategy to use when formatting numbers.
@@ -1456,8 +1658,6 @@ class U_I18N_API NumberFormatterSettings {
*/
Derived rounding(const Rounder &rounder) const;
-#ifndef U_HIDE_INTERNAL_API
-
/**
* Specifies the grouping strategy to use when formatting numbers.
*
@@ -1471,25 +1671,21 @@ class U_I18N_API NumberFormatterSettings {
* The exact grouping widths will be chosen based on the locale.
*
* <p>
- * Pass this method the return value of one of the factory methods on {@link Grouper}. For example:
+ * Pass this method an element from the {@link UGroupingStrategy} enum. For example:
*
* <pre>
- * NumberFormatter::with().grouping(Grouper::min2())
+ * NumberFormatter::with().grouping(UNUM_GROUPING_MIN2)
* </pre>
*
- * The default is to perform grouping without concern for the minimum grouping digits.
+ * The default is to perform grouping according to locale data; most locales, but not all locales,
+ * enable it by default.
*
- * @param grouper
+ * @param strategy
* The grouping strategy to use.
* @return The fluent chain.
- * @see Grouper
- * @see Notation
- * @internal
- * @internal ICU 60: This API is technical preview.
+ * @draft ICU 61
*/
- Derived grouping(const Grouper &grouper) const;
-
-#endif /* U_HIDE_INTERNAL_API */
+ Derived grouping(const UGroupingStrategy &strategy) const;
/**
* Specifies the minimum and maximum number of digits to render before the decimal mark.
@@ -1592,7 +1788,7 @@ class U_I18N_API NumberFormatterSettings {
* @see NumberingSystem
* @draft ICU 60
*/
- Derived adoptSymbols(const NumberingSystem *symbols) const;
+ Derived adoptSymbols(NumberingSystem *symbols) const;
/**
* Sets the width of the unit (measure unit or currency). Most common values:
diff --git a/deps/icu-small/source/i18n/unicode/numfmt.h b/deps/icu-small/source/i18n/unicode/numfmt.h
index d6b2a6d53c..1332f52566 100644
--- a/deps/icu-small/source/i18n/unicode/numfmt.h
+++ b/deps/icu-small/source/i18n/unicode/numfmt.h
@@ -28,7 +28,7 @@
/**
* \file
- * \brief C++ API: Abstract base class for all number formats.
+ * \brief C++ API: Compatibility APIs for number formatting.
*/
#if !UCONFIG_NO_FORMATTING
@@ -53,16 +53,16 @@ class StringEnumeration;
#endif
/**
+ * <p><strong>IMPORTANT:</strong> New users are strongly encouraged to see if
+ * numberformatter.h fits their use case. Although not deprecated, this header
+ * is provided for backwards compatibility only.
+ * <hr/>
*
* Abstract base class for all number formats. Provides interface for
* formatting and parsing a number. Also provides methods for
* determining which locales have number formats, and what their names
* are.
*
- * <p><strong>NOTE:</strong> Starting in ICU 60, there is a new set of APIs for localized number
- * formatting that are designed to be an improvement over DecimalFormat. New users are discouraged
- * from using DecimalFormat. For more information, see numberformatter.h.
- *
* \headerfile unicode/numfmt.h "unicode/numfmt.h"
* <P>
* NumberFormat helps you to format and parse numbers for any locale.
@@ -708,6 +708,9 @@ public:
/**
* Create a default style NumberFormat for the current default locale.
* The default formatting style is locale dependent.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
@@ -716,6 +719,9 @@ public:
* Create a default style NumberFormat for the specified locale.
* The default formatting style is locale dependent.
* @param inLocale the given locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
@@ -723,6 +729,9 @@ public:
/**
* Create a specific style NumberFormat for the specified locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param desiredLocale the given locale.
* @param style the given style.
* @param errorCode Output param filled with success/failure status.
@@ -759,12 +768,18 @@ public:
/**
* Returns a currency format for the current default locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
/**
* Returns a currency format for the specified locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
@@ -773,12 +788,18 @@ public:
/**
* Returns a percentage format for the current default locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
/**
* Returns a percentage format for the specified locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
@@ -787,12 +808,18 @@ public:
/**
* Returns a scientific format for the current default locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
/**
* Returns a scientific format for the specified locale.
+ * <p>
+ * <strong>NOTE:</strong> New users are strongly encouraged to use
+ * {@link NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
diff --git a/deps/icu-small/source/i18n/unicode/simpletz.h b/deps/icu-small/source/i18n/unicode/simpletz.h
index 1b23ab79d1..7f5f1664cc 100644
--- a/deps/icu-small/source/i18n/unicode/simpletz.h
+++ b/deps/icu-small/source/i18n/unicode/simpletz.h
@@ -647,7 +647,8 @@ public:
* Sets the amount of time in ms that the clock is advanced during DST.
* @param millisSavedDuringDST the number of milliseconds the time is
* advanced with respect to standard time when the daylight savings rules
- * are in effect. A positive number, typically one hour (3600000).
+ * are in effect. Typically one hour (+3600000). The amount could be negative,
+ * but not 0.
* @param status An UErrorCode to receive the status.
* @stable ICU 2.0
*/
@@ -657,7 +658,8 @@ public:
* Returns the amount of time in ms that the clock is advanced during DST.
* @return the number of milliseconds the time is
* advanced with respect to standard time when the daylight savings rules
- * are in effect. A positive number, typically one hour (3600000).
+ * are in effect. Typically one hour (+3600000). The amount could be negative,
+ * but not 0.
* @stable ICU 2.0
*/
virtual int32_t getDSTSavings(void) const;
diff --git a/deps/icu-small/source/i18n/unicode/udatpg.h b/deps/icu-small/source/i18n/unicode/udatpg.h
index 9e3bdd4114..54f1254346 100644
--- a/deps/icu-small/source/i18n/unicode/udatpg.h
+++ b/deps/icu-small/source/i18n/unicode/udatpg.h
@@ -95,6 +95,21 @@ typedef enum UDateTimePatternField {
UDATPG_FIELD_COUNT
} UDateTimePatternField;
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Field display name width constants for udatpg_getFieldDisplayName().
+ * @draft ICU 61
+ */
+typedef enum UDateTimePGDisplayWidth {
+ /** @draft ICU 61 */
+ UDATPG_WIDE,
+ /** @draft ICU 61 */
+ UDATPG_ABBREVIATED,
+ /** @draft ICU 61 */
+ UDATPG_NARROW
+} UDateTimePGDisplayWidth;
+#endif // U_HIDE_DRAFT_API
+
/**
* Masks to control forcing the length of specified fields in the returned
* pattern to match those in the skeleton (when this would not happen
@@ -410,12 +425,14 @@ udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
/**
* Getter corresponding to setAppendItemNames. Values below 0 or at or above
- * UDATPG_FIELD_COUNT are illegal arguments.
+ * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general function
+ * for getting date/time field display names is udatpg_getFieldDisplayName.
*
* @param dtpg a pointer to UDateTimePatternGenerator.
* @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
* @param pLength A pointer that will receive the length of the name for field.
* @return name for field
+ * @see udatpg_getFieldDisplayName
* @stable ICU 3.8
*/
U_STABLE const UChar * U_EXPORT2
@@ -423,6 +440,40 @@ udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength);
+#ifndef U_HIDE_DRAFT_API
+/**
+ * The general interface to get a display name for a particular date/time field,
+ * in one of several possible display widths.
+ *
+ * @param dtpg
+ * A pointer to the UDateTimePatternGenerator object with the localized
+ * display names.
+ * @param field
+ * The desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
+ * @param width
+ * The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
+ * @param fieldName
+ * A pointer to a buffer to receive the NULL-terminated display name. If the name
+ * fits into fieldName but cannot be NULL-terminated (length == capacity) then
+ * the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the name doesn't
+ * fit into fieldName then the error code is set to U_BUFFER_OVERFLOW_ERROR.
+ * @param capacity
+ * The size of fieldName (in UChars).
+ * @param pErrorCode
+ * A pointer to a UErrorCode to receive any errors
+ * @return
+ * The full length of the name; if greater than capacity, fieldName contains a
+ * truncated result.
+ * @draft ICU 61
+ */
+U_DRAFT int32_t U_EXPORT2
+udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
+ UDateTimePatternField field,
+ UDateTimePGDisplayWidth width,
+ UChar *fieldName, int32_t capacity,
+ UErrorCode *pErrorCode);
+#endif // U_HIDE_DRAFT_API
+
/**
* The DateTimeFormat is a message format pattern used to compose date and
* time patterns. The default pattern in the root locale is "{1} {0}", where
diff --git a/deps/icu-small/source/i18n/unicode/unum.h b/deps/icu-small/source/i18n/unicode/unum.h
index 9154bce661..0e7b9fffba 100644
--- a/deps/icu-small/source/i18n/unicode/unum.h
+++ b/deps/icu-small/source/i18n/unicode/unum.h
@@ -33,6 +33,9 @@
*
* <h2> Number Format C API </h2>
*
+ * <p><strong>IMPORTANT:</strong> New users with C++ capabilities are
+ * strongly encouraged to see if numberformatter.h fits their use case.
+ *
* Number Format C API Provides functions for
* formatting and parsing a number. Also provides methods for
* determining which locales have number formats, and what their names
@@ -559,7 +562,6 @@ unum_formatDouble( const UNumberFormat* fmt,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status);
-#ifndef U_HIDE_DRAFT_API
/**
* Format a double using a UNumberFormat according to the UNumberFormat's locale,
* and initialize a UFieldPositionIterator that enumerates the subcomponents of
@@ -600,9 +602,9 @@ unum_formatDouble( const UNumberFormat* fmt,
* @see unum_parseDouble
* @see UFieldPositionIterator
* @see UNumberFormatFields
-* @draft ICU 59
+* @stable ICU 59
*/
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
UChar* result,
@@ -610,7 +612,6 @@ unum_formatDoubleForFields(const UNumberFormat* format,
UFieldPositionIterator* fpositer,
UErrorCode* status);
-#endif /* U_HIDE_DRAFT_API */
/**
* Format a decimal number using a UNumberFormat.
diff --git a/deps/icu-small/source/i18n/unicode/upluralrules.h b/deps/icu-small/source/i18n/unicode/upluralrules.h
index 99d93a4e05..690846bc89 100644
--- a/deps/icu-small/source/i18n/unicode/upluralrules.h
+++ b/deps/icu-small/source/i18n/unicode/upluralrules.h
@@ -175,7 +175,6 @@ uplrules_selectWithFormat(const UPluralRules *uplrules,
#endif /* U_HIDE_INTERNAL_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Creates a string enumeration of all plural rule keywords used in this
* UPluralRules object. The rule "other" is always present by default.
@@ -184,12 +183,11 @@ uplrules_selectWithFormat(const UPluralRules *uplrules,
* @param status A pointer to a UErrorCode to receive any errors.
* @return a string enumeration over plural rule keywords, or NULL
* upon error. The caller is responsible for closing the result.
- * @draft ICU 59
+ * @stable ICU 59
*/
-U_DRAFT UEnumeration* U_EXPORT2
+U_STABLE UEnumeration* U_EXPORT2
uplrules_getKeywords(const UPluralRules *uplrules,
UErrorCode *status);
-#endif /* U_HIDE_DRAFT_API */
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unicode/utrans.h b/deps/icu-small/source/i18n/unicode/utrans.h
index a4158726ca..7672b4428f 100644
--- a/deps/icu-small/source/i18n/unicode/utrans.h
+++ b/deps/icu-small/source/i18n/unicode/utrans.h
@@ -382,7 +382,7 @@ utrans_openIDs(UErrorCode *pErrorCode);
U_STABLE void U_EXPORT2
utrans_trans(const UTransliterator* trans,
UReplaceable* rep,
- UReplaceableCallbacks* repFunc,
+ const UReplaceableCallbacks* repFunc,
int32_t start,
int32_t* limit,
UErrorCode* status);
@@ -433,7 +433,7 @@ utrans_trans(const UTransliterator* trans,
U_STABLE void U_EXPORT2
utrans_transIncremental(const UTransliterator* trans,
UReplaceable* rep,
- UReplaceableCallbacks* repFunc,
+ const UReplaceableCallbacks* repFunc,
UTransPosition* pos,
UErrorCode* status);