Issue #1971 - Part 2: Update ICU source to 63.2.

This commit is contained in:
Job Bautista 2022-07-24 21:03:27 +08:00 committed by roytam1
commit 1e69214382
3160 changed files with 275815 additions and 234203 deletions

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -15,6 +15,7 @@
#include "unicode/utypes.h"
#include "unicode/uobject.h"
#include "unicode/locid.h"
#include "unicode/unistr.h"
#if !UCONFIG_NO_COLLATION
@ -265,6 +266,8 @@ public:
* Use getBucket() to get the bucket's properties.
*
* @param name the string to be sorted into an index bucket
* @param errorCode Error code, will be set with the reason if the
* operation fails.
* @return the bucket number for the name
* @stable ICU 51
*/
@ -376,9 +379,10 @@ public:
/**
* Get the default label used for abbreviated buckets <i>between</i> other index characters.
* For example, consider the labels when Latin and Greek are used:
* X Y Z ... &#x0391; &#x0392; &#x0393;.
* Get the default label used for abbreviated buckets *between* other index characters.
* For example, consider the labels when Latin (X Y Z) and Greek (Α Β Γ) are used:
*
* X Y Z ... Α Β Γ.
*
* @return inflow label
* @stable ICU 4.8
@ -699,6 +703,7 @@ public:
/**
* A (name, data) pair, to be sorted by name into one of the index buckets.
* The user data is not used by the index implementation.
* \cond
* @internal
*/
struct Record: public UMemory {
@ -707,6 +712,7 @@ public:
Record(const UnicodeString &name, const void *data);
~Record();
};
/** \endcond */
#endif /* U_HIDE_INTERNAL_API */
private:

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -30,7 +30,7 @@
#include "unicode/utypes.h"
/**
* \file
* \file
* \brief C++ API: Calendar object
*/
#if !UCONFIG_NO_FORMATTING
@ -52,83 +52,64 @@ typedef int32_t UFieldResolutionTable[12][8];
class BasicTimeZone;
/**
* <code>Calendar</code> is an abstract base class for converting between
* a <code>UDate</code> object and a set of integer fields such as
* <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,
* and so on. (A <code>UDate</code> object represents a specific instant in
* `Calendar` is an abstract base class for converting between
* a `UDate` object and a set of integer fields such as
* `YEAR`, `MONTH`, `DAY`, `HOUR`, and so on.
* (A `UDate` object represents a specific instant in
* time with millisecond precision. See UDate
* for information about the <code>UDate</code> class.)
* for information about the `UDate` class.)
*
* <p>
* Subclasses of <code>Calendar</code> interpret a <code>UDate</code>
* Subclasses of `Calendar` interpret a `UDate`
* according to the rules of a specific calendar system.
* The most commonly used subclass of <code>Calendar</code> is
* <code>GregorianCalendar</code>. Other subclasses could represent
* The most commonly used subclass of `Calendar` is
* `GregorianCalendar`. Other subclasses could represent
* the various types of lunar calendars in use in many parts of the world.
*
* <p>
* <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable
* - it WILL change.
* **NOTE**: (ICU 2.6) The subclass interface should be considered unstable -
* it WILL change.
*
* <p>
* Like other locale-sensitive classes, <code>Calendar</code> provides a
* static method, <code>createInstance</code>, for getting a generally useful
* object of this type. <code>Calendar</code>'s <code>createInstance</code> method
* returns the appropriate <code>Calendar</code> subclass whose
* Like other locale-sensitive classes, `Calendar` provides a
* static method, `createInstance`, for getting a generally useful
* object of this type. `Calendar`'s `createInstance` method
* returns the appropriate `Calendar` subclass whose
* time fields have been initialized with the current date and time:
* \htmlonly<blockquote>\endhtmlonly
* <pre>
* Calendar *rightNow = Calendar::createInstance(errCode);
* </pre>
* \htmlonly</blockquote>\endhtmlonly
*
* <p>
* A <code>Calendar</code> object can produce all the time field values
* Calendar *rightNow = Calendar::createInstance(errCode);
*
* A `Calendar` object can produce all the time field values
* needed to implement the date-time formatting for a particular language
* and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
*
* <p>
* When computing a <code>UDate</code> from time fields, some special circumstances
* When computing a `UDate` from time fields, some special circumstances
* may arise: there may be insufficient information to compute the
* <code>UDate</code> (such as only year and month but no day in the month),
* `UDate` (such as only year and month but no day in the month),
* there may be inconsistent information (such as "Tuesday, July 15, 1996"
* -- July 15, 1996 is actually a Monday), or the input time might be ambiguous
* because of time zone transition.
*
* <p>
* <strong>Insufficient information.</strong> The calendar will use default
* **Insufficient information.** The calendar will use default
* information to specify the missing fields. This may vary by calendar; for
* the Gregorian calendar, the default for a field is the same as that of the
* start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
*
* <p>
* <strong>Inconsistent information.</strong> If fields conflict, the calendar
* **Inconsistent information.** If fields conflict, the calendar
* will give preference to fields set more recently. For example, when
* determining the day, the calendar will look for one of the following
* combinations of fields. The most recent combination, as determined by the
* most recently set single field, will be used.
*
* \htmlonly<blockquote>\endhtmlonly
* <pre>
* MONTH + DAY_OF_MONTH
* MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
* MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
* DAY_OF_YEAR
* DAY_OF_WEEK + WEEK_OF_YEAR
* </pre>
* \htmlonly</blockquote>\endhtmlonly
* MONTH + DAY_OF_MONTH
* MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
* MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
* DAY_OF_YEAR
* DAY_OF_WEEK + WEEK_OF_YEAR
*
* For the time of day:
*
* \htmlonly<blockquote>\endhtmlonly
* <pre>
* HOUR_OF_DAY
* AM_PM + HOUR
* </pre>
* \htmlonly</blockquote>\endhtmlonly
* HOUR_OF_DAY
* AM_PM + HOUR
*
* <p>
* <strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has
* **Ambiguous Wall Clock Time.** When time offset from UTC has
* changed, it produces an ambiguous time slot around the transition. For example,
* many US locations observe daylight saving time. On the date switching to daylight
* saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM
@ -137,65 +118,67 @@ class BasicTimeZone;
* Calendar resolves the time using the UTC offset before the transition by default.
* In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist),
* so the final result will be 2:30 AM daylight time.
*
* <p>On the date switching back to standard time, wall clock time is moved back one
*
* On the date switching back to standard time, wall clock time is moved back one
* hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this
* case, the ICU Calendar resolves the time using the UTC offset after the transition
* by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.
*
* <p>Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs
* Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs
* {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}.
* These methods are available in ICU 49 or later versions.
*
* <p>
* <strong>Note:</strong> for some non-Gregorian calendars, different
* **Note:** for some non-Gregorian calendars, different
* fields may be necessary for complete disambiguation. For example, a full
* specification of the historial Arabic astronomical calendar requires year,
* month, day-of-month <em>and</em> day-of-week in some cases.
* specification of the historical Arabic astronomical calendar requires year,
* month, day-of-month *and* day-of-week in some cases.
*
* <p>
* <strong>Note:</strong> There are certain possible ambiguities in
* **Note:** There are certain possible ambiguities in
* interpretation of certain singular times, which are resolved in the
* following ways:
* <ol>
* <li> 24:00:00 "belongs" to the following day. That is,
* 23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
*
* <li> Although historically not precise, midnight also belongs to "am",
* and noon belongs to "pm", so on the same day,
* 12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
* </ol>
* 1. 24:00:00 "belongs" to the following day. That is,
* 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970
* 2. Although historically not precise, midnight also belongs to "am",
* and noon belongs to "pm", so on the same day,
* 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm
*
* <p>
* The date or time format strings are not part of the definition of a
* calendar, as those must be modifiable or overridable by the user at
* runtime. Use {@link DateFormat}
* to format dates.
* runtime. Use `DateFormat` to format dates.
*
* <p>
* <code>Calendar</code> provides an API for field "rolling", where fields
* `Calendar` provides an API for field "rolling", where fields
* can be incremented or decremented, but wrap around. For example, rolling the
* month up in the date <code>December 12, <b>1996</b></code> results in
* <code>January 12, <b>1996</b></code>.
* month up in the date December 12, **1996** results in
* January 12, **1996**.
*
* `Calendar` also provides a date arithmetic function for
* adding the specified (signed) amount of time to a particular time field.
* For example, subtracting 5 days from the date `September 12, 1996`
* results in `September 7, 1996`.
*
* ***Supported range***
*
* The allowable range of `Calendar` has been narrowed. `GregorianCalendar` used
* to attempt to support the range of dates with millisecond values from
* `Long.MIN_VALUE` to `Long.MAX_VALUE`. The new `Calendar` protocol specifies the
* maximum range of supportable dates as those having Julian day numbers
* of `-0x7F000000` to `+0x7F000000`. This corresponds to years from ~5,800,000 BCE
* to ~5,800,000 CE. Programmers should use the protected constants in `Calendar` to
* specify an extremely early or extremely late date.
*
* <p>
* <code>Calendar</code> also provides a date arithmetic function for
* adding the specified (signed) amount of time to a particular time field.
* For example, subtracting 5 days from the date <code>September 12, 1996</code>
* results in <code>September 7, 1996</code>.
*
* <p><big><b>Supported range</b></big>
*
* <p>The allowable range of <code>Calendar</code> has been
* narrowed. <code>GregorianCalendar</code> used to attempt to support
* the range of dates with millisecond values from
* <code>Long.MIN_VALUE</code> to <code>Long.MAX_VALUE</code>.
* The new <code>Calendar</code> protocol specifies the
* maximum range of supportable dates as those having Julian day numbers
* of <code>-0x7F000000</code> to <code>+0x7F000000</code>. This
* corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers
* should use the protected constants in <code>Calendar</code> to
* specify an extremely early or extremely late date.</p>
* The Japanese calendar uses a combination of era name and year number.
* When an emperor of Japan abdicates and a new emperor ascends the throne,
* a new era is declared and year number is reset to 1. Even if the date of
* abdication is scheduled ahead of time, the new era name might not be
* announced until just before the date. In such case, ICU4C may include
* a start date of future era without actual era name, but not enabled
* by default. ICU4C users who want to test the behavior of the future era
* can enable the tentative era by:
* <ul>
* <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li>
* </ul>
*
* @stable ICU 2.0
*/
@ -235,7 +218,7 @@ public:
DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
EXTENDED_YEAR,
JULIAN_DAY,
MILLISECONDS_IN_DAY,
@ -903,7 +886,7 @@ public:
/**
* Sets the behavior for handling wall time repeating multiple times
* at negative time zone offset transitions. For example, 1:30 AM on
* November 6, 2011 in US Eastern time (Ameirca/New_York) occurs twice;
* November 6, 2011 in US Eastern time (America/New_York) occurs twice;
* 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code>
* is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT
* (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be
@ -914,7 +897,7 @@ public:
* option for this. When the argument is neither <code>UCAL_WALLTIME_FIRST</code>
* nor <code>UCAL_WALLTIME_LAST</code>, this method has no effect and will keep
* the current setting.
*
*
* @param option the behavior for handling repeating wall time, either
* <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
* @see #getRepeatedWallTimeOption
@ -925,7 +908,7 @@ public:
/**
* Gets the behavior for handling wall time repeating multiple times
* at negative time zone offset transitions.
*
*
* @return the behavior for handling repeating wall time, either
* <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
* @see #setRepeatedWallTimeOption
@ -946,12 +929,12 @@ public:
* <p>
* <b>Note:</b>This option is effective only when this calendar is lenient.
* When the calendar is strict, such non-existing wall time will cause an error.
*
*
* @param option the behavior for handling skipped wall time at positive time zone
* offset transitions, one of <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code> and
* <code>UCAL_WALLTIME_NEXT_VALID</code>.
* @see #getSkippedWallTimeOption
*
*
* @stable ICU 49
*/
void setSkippedWallTimeOption(UCalendarWallTimeOption option);
@ -959,7 +942,7 @@ public:
/**
* Gets the behavior for handling skipped wall time at positive time zone offset
* transitions.
*
*
* @return the behavior for handling skipped wall time, one of
* <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code>
* and <code>UCAL_WALLTIME_NEXT_VALID</code>.
@ -1718,9 +1701,7 @@ protected:
/**
* Validate a single field of this calendar. Subclasses should
* override this method to validate any calendar-specific fields.
* Generic fields can be handled by
* <code>Calendar::validateField()</code>.
* @see #validateField(int, int, int, int&)
* Generic fields can be handled by `Calendar::validateField()`.
* @internal
*/
virtual void validateField(UCalendarDateFields field, UErrorCode &status);
@ -1741,7 +1722,7 @@ protected:
* reflects local zone wall time.
* @internal
*/
int32_t computeMillisInDay();
double computeMillisInDay();
/**
* This method can assume EXTENDED_YEAR has been set.
@ -1752,7 +1733,7 @@ protected:
* when this function fails.
* @internal
*/
int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);
int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec);
/**
@ -2171,7 +2152,7 @@ private:
TimeZone* fZone;
/**
* Option for rpeated wall time
* Option for repeated wall time
* @see #setRepeatedWallTimeOption
*/
UCalendarWallTimeOption fRepeatedWallTime;
@ -2456,7 +2437,7 @@ private:
BasicTimeZone* getBasicTimeZone() const;
/**
* Find the previous zone transtion near the given time.
* Find the previous zone transition near the given time.
* @param base The base time, inclusive
* @param transitionTime Receives the result time
* @param status The error status

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
@ -47,6 +47,7 @@ U_NAMESPACE_BEGIN
struct CollationData;
class CharacterIterator;
class CollationIterator;
class RuleBasedCollator;
class UCollationPCE;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
@ -58,7 +58,7 @@
#include "unicode/uobject.h"
#include "unicode/ucol.h"
#include "unicode/normlzr.h"
#include "unicode/unorm.h"
#include "unicode/locid.h"
#include "unicode/uniset.h"
#include "unicode/umisc.h"
@ -158,7 +158,7 @@ class CollationKey;
* @see CollationKey
* @see CollationElementIterator
* @see Locale
* @see Normalizer
* @see Normalizer2
* @version 2.0 11/15/01
*/
@ -235,16 +235,16 @@ public:
* Returns TRUE if "other" is the same as "this".
*
* The base class implementation returns TRUE if "other" has the same type/class as "this":
* <code>typeid(*this) == typeid(other)</code>.
* `typeid(*this) == typeid(other)`.
*
* Subclass implementations should do something like the following:
* <pre>
* if (this == &other) { return TRUE; }
* if (!Collator::operator==(other)) { return FALSE; } // not the same class
*
* const MyCollator &o = (const MyCollator&)other;
* (compare this vs. o's subclass fields)
* </pre>
* if (this == &other) { return TRUE; }
* if (!Collator::operator==(other)) { return FALSE; } // not the same class
*
* const MyCollator &o = (const MyCollator&)other;
* (compare this vs. o's subclass fields)
*
* @param other Collator object to be compared
* @return TRUE if other is the same as this.
* @stable ICU 2.0
@ -393,8 +393,8 @@ public:
* is less than, greater than or equal to another string array.
* <p>Example of use:
* <pre>
* . UChar ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC"
* . UChar abc[] = {0x61, 0x62, 0x63, 0}; // = "abc"
* . char16_t ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC"
* . char16_t abc[] = {0x61, 0x62, 0x63, 0}; // = "abc"
* . UErrorCode status = U_ZERO_ERROR;
* . Collator *myCollation =
* . Collator::createInstance(Locale::getUS(), status);
@ -420,8 +420,8 @@ public:
* target
* @deprecated ICU 2.6 use the overload with UErrorCode &
*/
virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
const UChar* target, int32_t targetLength)
virtual EComparisonResult compare(const char16_t* source, int32_t sourceLength,
const char16_t* target, int32_t targetLength)
const;
/**
@ -440,8 +440,8 @@ public:
* than target
* @stable ICU 2.6
*/
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
const UChar* target, int32_t targetLength,
virtual UCollationResult compare(const char16_t* source, int32_t sourceLength,
const char16_t* target, int32_t targetLength,
UErrorCode &status) const = 0;
/**
@ -517,7 +517,7 @@ public:
* @see CollationKey#compare
* @stable ICU 2.0
*/
virtual CollationKey& getCollationKey(const UChar*source,
virtual CollationKey& getCollationKey(const char16_t*source,
int32_t sourceLength,
CollationKey& key,
UErrorCode& status) const = 0;
@ -672,7 +672,7 @@ public:
UErrorCode& status);
/**
* Get name of the object for the desired Locale, in the desired langauge
* Get name of the object for the desired Locale, in the desired language
* @param objectLocale must be from getAvailableLocales
* @param displayLocale specifies the desired locale for output
* @param name the fill-in parameter of the return value
@ -685,7 +685,7 @@ public:
UnicodeString& name);
/**
* Get name of the object for the desired Locale, in the langauge of the
* Get name of the object for the desired Locale, in the language of the
* default locale.
* @param objectLocale must be from getAvailableLocales
* @param name the fill-in parameter of the return value
@ -911,7 +911,7 @@ public:
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See setMaxVariable().
* @param varTop one or more (if contraction) UChars to which the variable top should be set
* @param varTop one or more (if contraction) char16_ts to which the variable top should be set
* @param len length of variable top string. If -1 it is considered to be zero terminated.
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
@ -920,7 +920,7 @@ public:
* @return variable top primary weight
* @deprecated ICU 53 Call setMaxVariable() instead.
*/
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status) = 0;
/**
* Sets the variable top to the primary weight of the specified string.
@ -929,7 +929,7 @@ public:
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See setMaxVariable().
* @param varTop a UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
* @param varTop a UnicodeString size 1 or more (if contraction) of char16_ts to which the variable top should be set
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
@ -1002,7 +1002,7 @@ public:
int32_t resultLength) const = 0;
/**
* Get the sort key as an array of bytes from a UChar buffer.
* Get the sort key as an array of bytes from a char16_t buffer.
* Sort key byte arrays are zero-terminated and can be compared using
* strcmp().
*
@ -1020,7 +1020,7 @@ public:
* @return Number of bytes needed for storing the sort key
* @stable ICU 2.2
*/
virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
virtual int32_t getSortKey(const char16_t*source, int32_t sourceLength,
uint8_t*result, int32_t resultLength) const = 0;
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -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,25 +30,31 @@ U_NAMESPACE_BEGIN
class PluralRules;
/**
* **IMPORTANT:** 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.
*
* -----------------------------------------------------------------------------
*
* 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,
* such as "1,2 Mrd." for German.
* <p>
*
* For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345),
* the result will be short for supported languages. However, the result may
* sometimes exceed 7 characters, such as when there are combining marks or thin
* characters. In such cases, the visual width in fonts should still be short.
* <p>
*
* By default, there are 3 significant digits. After creation, if more than
* three significant digits are set (with setMaximumSignificantDigits), or if a
* fixed number of digits are set (with setMaximumIntegerDigits or
* setMaximumFractionDigits), then result may be wider.
* <p>
*
* At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERROR.
* Resetting the pattern prefixes or suffixes is not supported; the method calls
* are ignored.
* <p>
*
* @stable ICU 51
*/
class U_I18N_API CompactDecimalFormat : public DecimalFormat {
@ -56,6 +62,9 @@ public:
/**
* Returns a compact decimal instance for specified locale.
*
* **NOTE:** New users are strongly encouraged to use
* `number::NumberFormatter` instead of NumberFormat.
* @param inLocale the given locale.
* @param style whether to use short or long style.
* @param status error code returned here.
@ -76,7 +85,7 @@ public:
* Destructor.
* @stable ICU 51
*/
virtual ~CompactDecimalFormat();
~CompactDecimalFormat() U_OVERRIDE;
/**
* Assignment operator.
@ -93,245 +102,21 @@ public:
* @return a polymorphic copy of this CompactDecimalFormat.
* @stable ICU 51
*/
virtual Format* clone() const;
/**
* Return TRUE if the given Format objects are semantically equal.
* Objects of different subclasses are considered unequal.
*
* @param other the object to be compared with.
* @return TRUE if the given Format objects are semantically equal.
* @stable ICU 51
*/
virtual UBool operator==(const Format& other) const;
Format* clone() const U_OVERRIDE;
using DecimalFormat::format;
/**
* Format a double or long number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* CompactDecimalFormat does not support parsing. This implementation
* does nothing.
* @param text Unused.
* @param result Does not change.
* @param parsePosition Does not change.
* @see Formattable
* @stable ICU 51
*/
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPosition& pos) const;
/**
* Format a double or long number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param status
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const;
/**
* Format a double or long number using base-10 representation.
* Currently sets status to U_UNSUPPORTED_ERROR.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* Can be NULL.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(double number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a long number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* @stable ICU 56
*/
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPosition& pos) const;
/**
* Format a long number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const;
/**
* Format a long number using base-10 representation.
* Currently sets status to U_UNSUPPORTED_ERROR
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* Can be NULL.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(int32_t number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format an int64 number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* @stable ICU 51
*/
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPosition& pos) const;
/**
* Format an int64 number using base-10 representation.
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode &status) const;
/**
* Format an int64 number using base-10 representation.
* Currently sets status to U_UNSUPPORTED_ERROR
*
* @param number The value to be formatted.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* Can be NULL.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(int64_t number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
* The syntax of the unformatted number is a "numeric string"
* as defined in the Decimal Arithmetic Specification, available at
* http://speleotrove.com/decimal
*
* @param number The unformatted number, as a string.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* Can be NULL.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(StringPiece number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
* The number is a DigitList wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const DigitList &number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR.
* The number is a DigitList wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const DigitList &number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
/**
* CompactDecimalFormat does not support parsing. This implementation
* does nothing.
* @param text Unused.
* @param result Does not change.
* @param parsePosition Does not change.
* @see Formattable
* @stable ICU 51
*/
virtual void parse(const UnicodeString& text,
Formattable& result,
ParsePosition& parsePosition) const;
void parse(const UnicodeString& text, Formattable& result,
ParsePosition& parsePosition) const U_OVERRIDE;
/**
* CompactDecimalFormat does not support parsing. This implementation
@ -342,10 +127,9 @@ public:
* @param status Always set to U_UNSUPPORTED_ERROR.
* @stable ICU 51
*/
virtual void parse(const UnicodeString& text,
Formattable& result,
UErrorCode& status) const;
void parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const U_OVERRIDE;
#ifndef U_HIDE_INTERNAL_API
/**
* Parses text from the given string as a currency amount. Unlike
* the parse() method, this method will attempt to parse a generic
@ -366,8 +150,8 @@ public:
* the parsed currency; if parse fails, this is NULL.
* @internal
*/
virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
ParsePosition& pos) const;
CurrencyAmount* parseCurrency(const UnicodeString& text, ParsePosition& pos) const U_OVERRIDE;
#endif /* U_HIDE_INTERNAL_API */
/**
* Return the class ID for this class. This is useful only for
@ -393,18 +177,10 @@ public:
* other classes have different class IDs.
* @stable ICU 51
*/
virtual UClassID getDynamicClassID() const;
UClassID getDynamicClassID() const U_OVERRIDE;
private:
const UHashtable* _unitsByVariant;
const double* _divisors;
PluralRules* _pluralRules;
// Default constructor not implemented.
CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
UBool eqHelper(const CompactDecimalFormat& that) const;
private:
CompactDecimalFormat(const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
};
U_NAMESPACE_END

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -46,7 +46,7 @@ class U_I18N_API CurrencyAmount: public Measure {
* is invalid, then this will be set to a failing value.
* @stable ICU 3.0
*/
CurrencyAmount(const Formattable& amount, const UChar* isoCode,
CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode,
UErrorCode &ec);
/**
@ -59,7 +59,7 @@ class U_I18N_API CurrencyAmount: public Measure {
* then this will be set to a failing value.
* @stable ICU 3.0
*/
CurrencyAmount(double amount, const UChar* isoCode,
CurrencyAmount(double amount, ConstChar16Ptr isoCode,
UErrorCode &ec);
/**
@ -115,14 +115,14 @@ class U_I18N_API CurrencyAmount: public Measure {
* Return the ISO currency code of this object.
* @stable ICU 3.0
*/
inline const UChar* getISOCurrency() const;
inline const char16_t* getISOCurrency() const;
};
inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
return (const CurrencyUnit&) getUnit();
}
inline const UChar* CurrencyAmount::getISOCurrency() const {
inline const char16_t* CurrencyAmount::getISOCurrency() const {
return getCurrency().getISOCurrency();
}

View file

@ -1,8 +1,8 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2015, International Business Machines Corporation and *
* Copyright (C) 2009-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -240,18 +240,27 @@ private:
/*
* The plural rule is used to format currency plural name,
* for example: "3.00 US Dollars".
* If there are 3 currency signs in the currency patttern,
* If there are 3 currency signs in the currency pattern,
* the 3 currency signs will be replaced by currency plural name.
*/
PluralRules* fPluralRules;
// locale
Locale* fLocale;
private:
/**
* An internal status variable used to indicate that the object is in an 'invalid' state.
* Used by copy constructor, the assignment operator and the clone method.
*/
UErrorCode fInternalStatus;
};
inline UBool
CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { return !operator==(info); }
CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {
return !operator==(info);
}
U_NAMESPACE_END

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -28,7 +28,7 @@ U_NAMESPACE_BEGIN
/**
* A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
* yen). This class is a thin wrapper over a UChar string that
* yen). This class is a thin wrapper over a char16_t string that
* subclasses MeasureUnit, for use with Measure and MeasureFormat.
*
* @author Alan Liu
@ -36,15 +36,22 @@ U_NAMESPACE_BEGIN
*/
class U_I18N_API CurrencyUnit: public MeasureUnit {
public:
/**
* Default constructor. Initializes currency code to "XXX" (no currency).
* @stable ICU 60
*/
CurrencyUnit();
/**
* Construct an object with the given ISO currency code.
* @param isoCode the 3-letter ISO 4217 currency code; must not be
* NULL and must have length 3
* @param isoCode the 3-letter ISO 4217 currency code; must have
* length 3 and need not be NUL-terminated. If NULL, the currency
* is initialized to the unknown currency XXX.
* @param ec input-output error code. If the isoCode is invalid,
* then this will be set to a failing value.
* @stable ICU 3.0
*/
CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
CurrencyUnit(ConstChar16Ptr isoCode, UErrorCode &ec);
/**
* Copy constructor
@ -52,6 +59,16 @@ class U_I18N_API CurrencyUnit: public MeasureUnit {
*/
CurrencyUnit(const CurrencyUnit& other);
/**
* Copy constructor from MeasureUnit. This constructor allows you to
* restore a CurrencyUnit that was sliced to MeasureUnit.
*
* @param measureUnit The MeasureUnit to copy from.
* @param ec Set to a failing value if the MeasureUnit is not a currency.
* @stable ICU 60
*/
CurrencyUnit(const MeasureUnit& measureUnit, UErrorCode &ec);
/**
* Assignment operator
* @stable ICU 3.0
@ -93,16 +110,16 @@ class U_I18N_API CurrencyUnit: public MeasureUnit {
* Return the ISO currency code of this object.
* @stable ICU 3.0
*/
inline const UChar* getISOCurrency() const;
inline const char16_t* getISOCurrency() const;
private:
/**
* The ISO 4217 code of this object.
*/
UChar isoCode[4];
char16_t isoCode[4];
};
inline const UChar* CurrencyUnit::getISOCurrency() const {
inline const char16_t* CurrencyUnit::getISOCurrency() const {
return isoCode;
}

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -43,12 +43,17 @@ U_NAMESPACE_BEGIN
class TimeZone;
class DateTimePatternGenerator;
// explicit template instantiation. see digitlst.h
#if defined (_MSC_VER)
/**
* \cond
* Export an explicit template instantiation. (See digitlst.h, datefmt.h, and others.)
* (When building DLLs for Windows this is required.)
*/
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN)
template class U_I18N_API EnumSet<UDateFormatBooleanAttribute,
0,
UDAT_BOOLEAN_ATTRIBUTE_COUNT>;
#endif
/** \endcond */
/**
* DateFormat is an abstract class for a family of classes that convert dates and

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -34,7 +34,9 @@
#include "unicode/uobject.h"
#include "unicode/locid.h"
#include "unicode/numsys.h"
#include "unicode/unum.h"
#include "unicode/unistr.h"
/**
* \file
@ -78,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:
@ -183,6 +181,24 @@ public:
*/
DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
/**
* Creates a DecimalFormatSymbols instance for the given locale with digits and symbols
* corresponding to the given NumberingSystem.
*
* This constructor behaves equivalently to the normal constructor called with a locale having a
* "numbers=xxxx" keyword specifying the numbering system by name.
*
* In this constructor, the NumberingSystem argument will be used even if the locale has its own
* "numbers=xxxx" keyword.
*
* @param locale The locale to get symbols for.
* @param ns The numbering system.
* @param status Input/output parameter, set to success or
* failure code upon return.
* @stable ICU 60
*/
DecimalFormatSymbols(const Locale& locale, const NumberingSystem& ns, UErrorCode& status);
/**
* Create a DecimalFormatSymbols object for the default locale.
* This constructor will not fail. If the resource file data is
@ -345,8 +361,11 @@ private:
* @param success Input/output parameter, set to success or
* failure code upon return.
* @param useLastResortData determine if use last resort data
* @param ns The NumberingSystem to use; otherwise, fall
* back to the locale.
*/
void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
void initialize(const Locale& locale, UErrorCode& success,
UBool useLastResortData = FALSE, const NumberingSystem* ns = nullptr);
/**
* Initialize the symbols with default values.
@ -371,6 +390,13 @@ public:
inline UBool isCustomIntlCurrencySymbol() const {
return fIsCustomIntlCurrencySymbol;
}
/**
* @internal For ICU use only
*/
inline UChar32 getCodePointZero() const {
return fCodePointZero;
}
#endif /* U_HIDE_INTERNAL_API */
/**
@ -378,21 +404,41 @@ public:
* returning a const reference to one of the symbol strings.
* The returned reference becomes invalid when the symbol is changed
* or when the DecimalFormatSymbols are destroyed.
* ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.
* Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat
* Note: moved \#ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat
*
* This is not currently stable API, but if you think it should be stable,
* post a comment on the following ticket and the ICU team will take a look:
* http://bugs.icu-project.org/trac/ticket/13580
*
* @param symbol Constant to indicate a number format symbol.
* @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.
*
* This is not currently stable API, but if you think it should be stable,
* post a comment on the following ticket and the ICU team will take a look:
* http://bugs.icu-project.org/trac/ticket/13580
*
* @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
*/
inline const UChar* getCurrencyPattern(void) const;
inline const char16_t* getCurrencyPattern(void) const;
#endif /* U_HIDE_INTERNAL_API */
private:
@ -419,11 +465,27 @@ 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];
char validLocale[ULOC_FULLNAME_CAPACITY];
const UChar* currPattern;
const char16_t* currPattern;
UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
@ -444,7 +506,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;
@ -456,6 +518,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 /* U_HIDE_INTERNAL_API */
// -------------------------------------
inline void
@ -472,14 +547,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;
}
}
@ -491,7 +572,7 @@ DecimalFormatSymbols::getLocale() const {
}
#ifndef U_HIDE_INTERNAL_API
inline const UChar*
inline const char16_t*
DecimalFormatSymbols::getCurrencyPattern() const {
return currPattern;
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -25,6 +25,7 @@
#if !UCONFIG_NO_FORMATTING
#include "unicode/calendar.h"
#include "unicode/strenum.h"
#include "unicode/uobject.h"
#include "unicode/locid.h"
#include "unicode/udat.h"
@ -426,13 +427,13 @@ public:
* doesn't specify any time separator, and always recognized when parsing.
* @internal
*/
static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
/**
* This alternate time separator is always recognized when parsing.
* @internal
*/
static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
/**
* Gets the time separator string. For example: ":".
@ -566,7 +567,7 @@ public:
* @return the non-localized date-time pattern characters
* @stable ICU 2.0
*/
static const UChar * U_EXPORT2 getPatternUChars(void);
static const char16_t * U_EXPORT2 getPatternUChars(void);
/**
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
@ -977,7 +978,7 @@ private:
* Returns the date format field index of the pattern character c,
* or UDAT_FIELD_COUNT if c is not a pattern character.
*/
static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
/**
* Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
@ -987,7 +988,7 @@ private:
/**
* Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
*/
static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
public:
#ifndef U_HIDE_INTERNAL_API
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************************
* Copyright (C) 2008-2016, International Business Machines Corporation and
@ -996,7 +996,7 @@ private:
// from calendar field to pattern letter
static const UChar fgCalendarFieldToPatternLetter[];
static const char16_t fgCalendarFieldToPatternLetter[];
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -152,8 +152,6 @@ U_NAMESPACE_BEGIN
class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
public:
// Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
// or else the compiler will create a public default constructor.
/**
* Default constructor.
* It does not initialize any interval patterns except

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -18,6 +18,7 @@
#include "unicode/locid.h"
#include "unicode/udat.h"
#include "unicode/udatpg.h"
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
@ -27,6 +28,7 @@ U_NAMESPACE_BEGIN
*/
class CharString;
class Hashtable;
class FormatParser;
class DateTimeMatcher;
@ -205,11 +207,11 @@ public:
* @return conflicting status. The value could be UDATPG_NO_CONFLICT,
* UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample
* <p>
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample
* <p>
*/
UDateTimePatternConflict addPattern(const UnicodeString& pattern,
UBool override,
@ -261,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
@ -311,11 +328,11 @@ public:
* @return bestPattern
* The best pattern found from the given skeleton.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample
* <p>
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample
* <p>
*/
UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
@ -359,11 +376,11 @@ public:
* which must not indicate a failure before the function call.
* @return pattern adjusted to match the skeleton fields widths and subtypes.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample
* <p>
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample
* <p>
*/
UnicodeString replaceFieldTypes(const UnicodeString& pattern,
const UnicodeString& skeleton,
@ -481,53 +498,57 @@ public:
private:
/**
* Constructor.
* @stable ICU 3.8
*/
DateTimePatternGenerator(UErrorCode & status);
/**
* Constructor.
* @stable ICU 3.8
*/
DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
/**
* Copy constructor.
* @param other DateTimePatternGenerator to copy
* @stable ICU 3.8
*/
DateTimePatternGenerator(const DateTimePatternGenerator& other);
/**
* Default assignment operator.
* @param other DateTimePatternGenerator to copy
* @stable ICU 3.8
*/
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;
Hashtable *fAvailableFormatKeyHash;
UnicodeString emptyString;
UChar fDefaultHourFormatChar;
char16_t fDefaultHourFormatChar;
int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
// Internal error code used for recording/reporting errors that occur during methods that do not
// have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method.
// When this is set to an error the object is in an invalid state.
UErrorCode internalErrorCode;
/* internal flags masks for adjustFieldTypes etc. */
enum {
kDTPGNoFlags = 0,
kDTPGFixFractionalSeconds = 1,
kDTPGSkeletonUsesCapJ = 2,
kDTPGSkeletonUsesLowB = 3,
kDTPGSkeletonUsesCapB = 4
kDTPGSkeletonUsesCapJ = 2
// with #13183, no longer need flags for b, B
};
void initData(const Locale &locale, UErrorCode &status);
@ -542,14 +563,17 @@ 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);
int32_t getCanonicalIndex(const UnicodeString& field);
const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status);
const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0);
UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
int32_t getTopBitNumber(int32_t foundMask);
UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
int32_t getTopBitNumber(int32_t foundMask) const;
void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
UBool isAvailableFormatSet(const UnicodeString &key) const;
void copyHashtable(Hashtable *other, UErrorCode &status);

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -33,17 +33,11 @@
U_NAMESPACE_BEGIN
class CharString;
class DigitList;
/**
* \def UNUM_INTERNAL_STACKARRAY_SIZE
* @internal
*/
#if U_PLATFORM == U_PF_OS400
#define UNUM_INTERNAL_STACKARRAY_SIZE 144
#else
#define UNUM_INTERNAL_STACKARRAY_SIZE 128
#endif
namespace number {
namespace impl {
class DecimalQuantity;
}
}
/**
* Formattable objects can be passed to the Format class or
@ -649,24 +643,25 @@ public:
* Internal function, do not use.
* TODO: figure out how to make this be non-public.
* NumberFormat::format(Formattable, ...
* needs to get at the DigitList, if it exists, for
* needs to get at the DecimalQuantity, if it exists, for
* big decimal formatting.
* @internal
*/
DigitList *getDigitList() const { return fDecimalNum;}
number::impl::DecimalQuantity *getDecimalQuantity() const { return fDecimalQuantity;}
/**
* @internal
* Export the value of this Formattable to a DecimalQuantity.
* @internal
*/
DigitList *getInternalDigitList();
void populateDecimalQuantity(number::impl::DecimalQuantity& output, UErrorCode& status) const;
/**
* Adopt, and set value from, a DigitList
* Adopt, and set value from, a DecimalQuantity
* Internal Function, do not use.
* @param dl the Digit List to be adopted
* @param dq the DecimalQuantity to be adopted
* @internal
*/
void adoptDigitList(DigitList *dl);
void adoptDecimalQuantity(number::impl::DecimalQuantity *dq);
/**
* Internal function to return the CharString pointer.
@ -706,9 +701,7 @@ private:
CharString *fDecimalStr;
DigitList *fDecimalNum;
char fStackData[UNUM_INTERNAL_STACKARRAY_SIZE]; // must be big enough for DigitList
number::impl::DecimalQuantity *fDecimalQuantity;
Type fType;
UnicodeString fBogus; // Bogus string when it's needed.

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -99,8 +99,6 @@ public:
UBool next(FieldPosition& fp);
private:
friend class FieldPositionIteratorHandler;
/**
* Sets the data used by the iterator, and resets the position.
* Returns U_ILLEGAL_ARGUMENT_ERROR in status if the data is not valid
@ -108,6 +106,8 @@ private:
*/
void setData(UVector32 *adopt, UErrorCode& status);
friend class FieldPositionIteratorHandler;
UVector32 *data;
int32_t pos;
};

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -18,6 +18,11 @@
#ifndef _GENDER
#define _GENDER
/**
* \file
* \brief C++ API: GenderInfo computes the gender of a list.
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
@ -30,7 +35,7 @@ class GenderInfoTest;
U_NAMESPACE_BEGIN
// Forward Declaration
/** \internal Forward Declaration */
void U_CALLCONV GenderInfo_initCache(UErrorCode &status);
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
* Copyright (C) 1997-2013, International Business Machines Corporation and others.

View file

@ -0,0 +1,203 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2012-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: listformatter.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 20120426
* created by: Umesh P. Nair
*/
#ifndef __LISTFORMATTER_H__
#define __LISTFORMATTER_H__
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/locid.h"
U_NAMESPACE_BEGIN
class FieldPositionIterator;
class FieldPositionHandler;
/** @internal */
class Hashtable;
/** @internal */
struct ListFormatInternal;
/* The following can't be #ifndef U_HIDE_INTERNAL_API, needed for other .h file declarations */
/**
* @internal
* \cond
*/
struct ListFormatData : public UMemory {
UnicodeString twoPattern;
UnicodeString startPattern;
UnicodeString middlePattern;
UnicodeString endPattern;
ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) :
twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {}
};
/** \endcond */
/**
* \file
* \brief C++ API: API for formatting a list.
*/
/**
* An immutable class for formatting a list, using data from CLDR (or supplied
* separately).
*
* Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted
* as "Alice, Bob, Charlie and Delta" in English.
*
* The ListFormatter class is not intended for public subclassing.
* @stable ICU 50
*/
class U_I18N_API ListFormatter : public UObject{
public:
/**
* Copy constructor.
* @stable ICU 52
*/
ListFormatter(const ListFormatter&);
/**
* Assignment operator.
* @stable ICU 52
*/
ListFormatter& operator=(const ListFormatter& other);
/**
* Creates a ListFormatter appropriate for the default locale.
*
* @param errorCode ICU error code, set if no data available for default locale.
* @return Pointer to a ListFormatter object for the default locale,
* created from internal data derived from CLDR data.
* @stable ICU 50
*/
static ListFormatter* createInstance(UErrorCode& errorCode);
/**
* Creates a ListFormatter appropriate for a locale.
*
* @param locale The locale.
* @param errorCode ICU error code, set if no data available for the given locale.
* @return A ListFormatter object created from internal data derived from
* CLDR data.
* @stable ICU 50
*/
static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);
#ifndef U_HIDE_INTERNAL_API
/**
* Creates a ListFormatter appropriate for a locale and style.
*
* @param locale The locale.
* @param style the style, either "standard", "duration", or "duration-short"
* @param errorCode ICU error code, set if no data available for the given locale.
* @return A ListFormatter object created from internal data derived from
* CLDR data.
* @internal
*/
static ListFormatter* createInstance(const Locale& locale, const char* style, UErrorCode& errorCode);
#endif /* U_HIDE_INTERNAL_API */
/**
* Destructor.
*
* @stable ICU 50
*/
virtual ~ListFormatter();
/**
* Formats a list of strings.
*
* @param items An array of strings to be combined and formatted.
* @param n_items Length of the array items.
* @param appendTo The string to which the result should be appended to.
* @param errorCode ICU error code, set if there is an error.
* @return Formatted string combining the elements of items, appended to appendTo.
* @stable ICU 50
*/
UnicodeString& format(const UnicodeString items[], int32_t n_items,
UnicodeString& appendTo, UErrorCode& errorCode) const;
#ifndef U_HIDE_DRAFT_API
/**
* Format a list of strings.
*
* @param items An array of strings to be combined and formatted.
* @param n_items Length of the array items.
* @param appendTo The string to which the formatted result will be
* appended.
* @param posIter On return, can be used to iterate over positions of
* fields generated by this format call. Field values are
* defined in UListFormatterField. Can be NULL.
* @param errorCode ICU error code returned here.
* @return Formatted string combining the elements of items,
* appended to appendTo.
* @draft ICU 63
*/
UnicodeString& format(const UnicodeString items[], int32_t n_items,
UnicodeString & appendTo, FieldPositionIterator* posIter,
UErrorCode& errorCode) const;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_INTERNAL_API
/**
@internal for MeasureFormat
*/
UnicodeString& format(
const UnicodeString items[],
int32_t n_items,
UnicodeString& appendTo,
int32_t index,
int32_t &offset,
UErrorCode& errorCode) const;
/**
* @internal constructor made public for testing.
*/
ListFormatter(const ListFormatData &data, UErrorCode &errorCode);
/**
* @internal constructor made public for testing.
*/
ListFormatter(const ListFormatInternal* listFormatterInternal);
#endif /* U_HIDE_INTERNAL_API */
private:
static void initializeHash(UErrorCode& errorCode);
static const ListFormatInternal* getListFormatInternal(const Locale& locale, const char *style, UErrorCode& errorCode);
struct ListPatternsSink;
static ListFormatInternal* loadListFormatInternal(const Locale& locale, const char* style, UErrorCode& errorCode);
UnicodeString& format_(
const UnicodeString items[], int32_t n_items, UnicodeString& appendTo,
int32_t index, int32_t &offset, FieldPositionHandler* handler, UErrorCode& errorCode) const;
ListFormatter();
ListFormatInternal* owned;
const ListFormatInternal* data;
};
U_NAMESPACE_END
#endif

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -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 icu::number::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 icu::number::NumberFormatter} instead of NumberFormat.
* @stable ICU 53
*/
MeasureFormat(
@ -195,7 +202,7 @@ class U_I18N_API MeasureFormat : public Format {
* formatted string is 3.5 meters per second.
* @param measure The measure object. In above example, 3.5 meters.
* @param perUnit The per unit. In above example, it is
* *MeasureUnit::createSecond(status).
* `*%MeasureUnit::createSecond(status)`.
* @param appendTo formatted string appended here.
* @param pos the field position.
* @param status the error.
@ -210,25 +217,26 @@ class U_I18N_API MeasureFormat : public Format {
FieldPosition &pos,
UErrorCode &status) const;
#ifndef U_HIDE_DRAFT_API
/**
* Gets the display name of the specified {@link MeasureUnit} corresponding to the current
* locale and format width.
* @param unit The unit for which to get a display name.
* @param status the error.
* @return The display name in the locale and width specified in
* {@link MeasureFormat#getInstance}, or null if there is no display name available
* the MeasureFormat constructor, or null if there is no display name available
* for the specified unit.
*
* @draft ICU 58
* @stable ICU 58
*/
UnicodeString getUnitDisplayName(const MeasureUnit& unit, UErrorCode &status) const;
#endif /* U_HIDE_DRAFT_API */
/**
* Return a formatter for CurrencyAmount objects in the given
* locale.
* <p>
* <strong>NOTE:</strong> New users are strongly encouraged to use
* {@link icu::number::NumberFormatter} instead of NumberFormat.
* @param locale desired locale
* @param ec input-output error code
* @return a formatter object, or NULL upon error
@ -240,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 icu::number::NumberFormatter} instead of NumberFormat.
* @param ec input-output error code
* @return a formatter object, or NULL upon error
* @stable ICU 3.0
@ -337,7 +348,7 @@ class U_I18N_API MeasureFormat : public Format {
const MeasureFormatCacheData *cache;
const SharedNumberFormat *numberFormat;
const SharedPluralRules *pluralRules;
UMeasureFormatWidth width;
UMeasureFormatWidth fWidth;
// Declared outside of MeasureFormatSharedData because ListFormatter
// objects are relatively cheap to copy; therefore, they don't need to be

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -40,11 +40,10 @@ class U_I18N_API MeasureUnit: public UObject {
/**
* Default constructor.
* Populates the instance with the base dimensionless unit.
* @stable ICU 3.0
*/
MeasureUnit() : fTypeId(0), fSubTypeId(0) {
fCurrency[0] = 0;
}
MeasureUnit();
/**
* Copy constructor.
@ -149,7 +148,7 @@ class U_I18N_API MeasureUnit: public UObject {
* <pre>
* . Base* polymorphic_pointer = createPolymorphicObject();
* . if (polymorphic_pointer->getDynamicClassID() ==
* . erived::getStaticClassID()) ...
* . Derived::getStaticClassID()) ...
* </pre>
* @return The class ID for all objects of this class.
* @stable ICU 53
@ -197,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
@ -345,35 +344,49 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createKarat(UErrorCode &status);
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of concentr: milligram-per-deciliter.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 57
* @stable ICU 57
*/
static MeasureUnit *createMilligramPerDeciliter(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of concentr: millimole-per-liter.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 57
* @stable ICU 57
*/
static MeasureUnit *createMillimolePerLiter(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of concentr: part-per-million.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 57
* @stable ICU 57
*/
static MeasureUnit *createPartPerMillion(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of concentr: percent.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 63
*/
static MeasureUnit *createPercent(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of concentr: permille.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 63
*/
static MeasureUnit *createPermille(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of consumption: liter-per-100kilometers.
@ -399,55 +412,13 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createMilePerGallon(UErrorCode &status);
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of consumption: mile-per-gallon-imperial.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 57
* @stable ICU 57
*/
static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of coordinate: east.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 58
*/
static MeasureUnit *createEast(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of coordinate: north.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 58
*/
static MeasureUnit *createNorth(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of coordinate: south.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 58
*/
static MeasureUnit *createSouth(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of coordinate: west.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 58
*/
static MeasureUnit *createWest(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of digital: bit.
@ -513,6 +484,16 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createMegabyte(UErrorCode &status);
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of digital: petabyte.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 63
*/
static MeasureUnit *createPetabyte(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of digital: terabit.
* Caller owns returned value and must free it.
@ -873,6 +854,14 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createPicometer(UErrorCode &status);
/**
* Returns unit of length: point.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @stable ICU 59
*/
static MeasureUnit *createPoint(UErrorCode &status);
/**
* Returns unit of length: yard.
* Caller owns returned value and must free it.
@ -1025,6 +1014,16 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createWatt(UErrorCode &status);
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of pressure: atmosphere.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 63
*/
static MeasureUnit *createAtmosphere(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of pressure: hectopascal.
* Caller owns returned value and must free it.
@ -1249,15 +1248,13 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit *createGallon(UErrorCode &status);
#ifndef U_HIDE_DRAFT_API
/**
* Returns unit of volume: gallon-imperial.
* Caller owns returned value and must free it.
* @param status ICU error code.
* @draft ICU 57
* @stable ICU 57
*/
static MeasureUnit *createGallonImperial(UErrorCode &status);
#endif /* U_HIDE_DRAFT_API */
/**
* Returns unit of volume: hectoliter.
@ -1349,6 +1346,12 @@ class U_I18N_API MeasureUnit: public UObject {
*/
void initCurrency(const char *isoCurrency);
/**
* For ICU use only.
* @internal
*/
void initNoUnit(const char *subtype);
#endif /* U_HIDE_INTERNAL_API */
private:

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
* Copyright (C) 2007-2013, International Business Machines Corporation and
@ -124,7 +124,7 @@ class NumberFormat;
* argNumber = '0' | ('1'..'9' ('0'..'9')*)
*
* argType = "number" | "date" | "time" | "spellout" | "ordinal" | "duration"
* argStyle = "short" | "medium" | "long" | "full" | "integer" | "currency" | "percent" | argStyleText
* argStyle = "short" | "medium" | "long" | "full" | "integer" | "currency" | "percent" | argStyleText | "::" argSkeletonText
* </pre>
*
* <ul>
@ -166,7 +166,7 @@ class NumberFormat;
* <td colspan=2><i>(none)</i>
* <td><code>null</code>
* <tr>
* <td rowspan=5><code>number</code>
* <td rowspan=6><code>number</code>
* <td><i>(none)</i>
* <td><code>NumberFormat.createInstance(getLocale(), status)</code>
* <tr>
@ -182,6 +182,9 @@ class NumberFormat;
* <td><i>argStyleText</i>
* <td><code>new DecimalFormat(argStyleText, new DecimalFormatSymbols(getLocale(), status), status)</code>
* <tr>
* <td><i>argSkeletonText</i>
* <td><code>NumberFormatter::forSkeleton(argSkeletonText, status).locale(getLocale()).toFormat(status)</code>
* <tr>
* <td rowspan=6><code>date</code>
* <td><i>(none)</i>
* <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code>
@ -199,7 +202,7 @@ class NumberFormat;
* <td><code>DateFormat.createDateInstance(kFull, getLocale(), status)</code>
* <tr>
* <td><i>argStyleText</i>
* <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)
* <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)</code>
* <tr>
* <td rowspan=6><code>time</code>
* <td><i>(none)</i>
@ -218,7 +221,7 @@ class NumberFormat;
* <td><code>DateFormat.createTimeInstance(kFull, getLocale(), status)</code>
* <tr>
* <td><i>argStyleText</i>
* <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)
* <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)</code>
* <tr>
* <td><code>spellout</code>
* <td><i>argStyleText (optional)</i>
@ -939,7 +942,7 @@ private:
* @return the index of the list which matches the keyword s.
*/
static int32_t findKeyword( const UnicodeString& s,
const UChar * const *list);
const char16_t * const *list);
/**
* Thin wrapper around the format(... AppendableWrapper ...) variant.

View file

@ -0,0 +1,111 @@
// © 2017 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2017, International Business Machines Corporation, *
* Google, and others. All Rights Reserved. *
*******************************************************************************
*/
#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
*/
U_NAMESPACE_BEGIN
#ifndef U_HIDE_DRAFT_API
/**
* Dimensionless unit for percent and permille.
* @see NumberFormatter
* @draft ICU 60
*/
class U_I18N_API NoUnit: public MeasureUnit {
public:
/**
* Returns an instance for the base unit (dimensionless and no scaling).
*
* @return a NoUnit instance
* @draft ICU 60
*/
static NoUnit U_EXPORT2 base();
/**
* Returns an instance for percent, or 1/100 of a base unit.
*
* @return a NoUnit instance
* @draft ICU 60
*/
static NoUnit U_EXPORT2 percent();
/**
* Returns an instance for permille, or 1/1000 of a base unit.
*
* @return a NoUnit instance
* @draft ICU 60
*/
static NoUnit U_EXPORT2 permille();
/**
* Copy operator.
* @draft ICU 60
*/
NoUnit(const NoUnit& other);
/**
* Destructor.
* @draft ICU 60
*/
virtual ~NoUnit();
/**
* Return a polymorphic clone of this object. The result will
* have the same class as returned by getDynamicClassID().
* @draft ICU 60
*/
virtual UObject* clone() const;
/**
* Returns a unique class ID for this object POLYMORPHICALLY.
* This method implements a simple form of RTTI used by ICU.
* @return The class ID for this object. All objects of a given
* class have the same class ID. Objects of other classes have
* different class IDs.
* @draft ICU 60
*/
virtual UClassID getDynamicClassID() const;
/**
* Returns the class ID for this class. This is used to compare to
* the return value of getDynamicClassID().
* @return The class ID for all objects of this class.
* @draft ICU 60
*/
static UClassID U_EXPORT2 getStaticClassID();
private:
/**
* Constructor
* @internal (private)
*/
NoUnit(const char* subtype);
};
#endif /* U_HIDE_DRAFT_API */
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif // __NOUNIT_H__
//eof
//

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,872 @@
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#if !UCONFIG_NO_FORMATTING
#ifndef __NUMBERRANGEFORMATTER_H__
#define __NUMBERRANGEFORMATTER_H__
#include <atomic>
#include "unicode/appendable.h"
#include "unicode/fieldpos.h"
#include "unicode/fpositer.h"
#include "unicode/numberformatter.h"
#ifndef U_HIDE_DRAFT_API
/**
* \file
* \brief C++ API: Library for localized formatting of number, currency, and unit ranges.
*
* The main entrypoint to the formatting of ranges of numbers, including currencies and other units of measurement.
* <p>
* Usage example:
* <p>
* <pre>
* NumberRangeFormatter::with()
* .identityFallback(UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE)
* .numberFormatterFirst(NumberFormatter::with().adoptUnit(MeasureUnit::createMeter()))
* .numberFormatterSecond(NumberFormatter::with().adoptUnit(MeasureUnit::createKilometer()))
* .locale("en-GB")
* .formatRange(750, 1.2, status)
* .toString(status);
* // => "750 m - 1.2 km"
* </pre>
* <p>
* Like NumberFormatter, NumberRangeFormatter instances are immutable and thread-safe. This API is based on the
* <em>fluent</em> design pattern popularized by libraries such as Google's Guava.
*
* @author Shane Carr
*/
/**
* Defines how to merge fields that are identical across the range sign.
*
* @draft ICU 63
*/
typedef enum UNumberRangeCollapse {
/**
* Use locale data and heuristics to determine how much of the string to collapse. Could end up collapsing none,
* some, or all repeated pieces in a locale-sensitive way.
*
* The heuristics used for this option are subject to change over time.
*
* @draft ICU 63
*/
UNUM_RANGE_COLLAPSE_AUTO,
/**
* Do not collapse any part of the number. Example: "3.2 thousand kilograms 5.3 thousand kilograms"
*
* @draft ICU 63
*/
UNUM_RANGE_COLLAPSE_NONE,
/**
* Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand 5.3 thousand
* kilograms"
*
* @draft ICU 63
*/
UNUM_RANGE_COLLAPSE_UNIT,
/**
* Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the
* number. Example: "3.2 5.3 thousand kilograms"
*
* @draft ICU 63
*/
UNUM_RANGE_COLLAPSE_ALL
} UNumberRangeCollapse;
/**
* Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect
* when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber.
*
* @draft ICU 63
* @see NumberRangeFormatter
*/
typedef enum UNumberRangeIdentityFallback {
/**
* Show the number as a single value rather than a range. Example: "$5"
*
* @draft ICU 63
*/
UNUM_IDENTITY_FALLBACK_SINGLE_VALUE,
/**
* Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding,
* show the single value. Example: "~$5" or "$5"
*
* @draft ICU 63
*/
UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE,
/**
* Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the
* inputs are the same. Example: "~$5"
*
* @draft ICU 63
*/
UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
/**
* Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the
* same. Example (with RangeCollapse.NONE): "$5 $5"
*
* @draft ICU 63
*/
UNUM_IDENTITY_FALLBACK_RANGE
} UNumberRangeIdentityFallback;
/**
* Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range
* were equal or not, and whether or not the identity fallback was applied.
*
* @draft ICU 63
* @see NumberRangeFormatter
*/
typedef enum UNumberRangeIdentityResult {
/**
* Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied.
*
* @draft ICU 63
* @see NumberRangeFormatter
*/
UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING,
/**
* Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied.
*
* @draft ICU 63
* @see NumberRangeFormatter
*/
UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING,
/**
* Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied.
*
* @draft ICU 63
* @see NumberRangeFormatter
*/
UNUM_IDENTITY_RESULT_NOT_EQUAL,
#ifndef U_HIDE_INTERNAL_API
/**
* The number of entries in this enum.
* @internal
*/
UNUM_IDENTITY_RESULT_COUNT
#endif
} UNumberRangeIdentityResult;
U_NAMESPACE_BEGIN
namespace number { // icu::number
// Forward declarations:
class UnlocalizedNumberRangeFormatter;
class LocalizedNumberRangeFormatter;
class FormattedNumberRange;
namespace impl {
// Forward declarations:
struct RangeMacroProps;
class DecimalQuantity;
struct UFormattedNumberRangeData;
class NumberRangeFormatterImpl;
} // namespace impl
/**
* \cond
* Export an explicit template instantiation. See datefmt.h
* (When building DLLs for Windows this is required.)
*/
#if U_PLATFORM == U_PF_WINDOWS && !defined(U_IN_DOXYGEN)
} // namespace icu::number
U_NAMESPACE_END
template struct U_I18N_API std::atomic< U_NAMESPACE_QUALIFIER number::impl::NumberRangeFormatterImpl*>;
U_NAMESPACE_BEGIN
namespace number { // icu::number
#endif
/** \endcond */
// Other helper classes would go here, but there are none.
namespace impl { // icu::number::impl
// Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
/** @internal */
struct U_I18N_API RangeMacroProps : public UMemory {
/** @internal */
UnlocalizedNumberFormatter formatter1; // = NumberFormatter::with();
/** @internal */
UnlocalizedNumberFormatter formatter2; // = NumberFormatter::with();
/** @internal */
bool singleFormatter = true;
/** @internal */
UNumberRangeCollapse collapse = UNUM_RANGE_COLLAPSE_AUTO;
/** @internal */
UNumberRangeIdentityFallback identityFallback = UNUM_IDENTITY_FALLBACK_APPROXIMATELY;
/** @internal */
Locale locale;
// NOTE: Uses default copy and move constructors.
/**
* Check all members for errors.
* @internal
*/
bool copyErrorTo(UErrorCode &status) const {
return formatter1.copyErrorTo(status) || formatter2.copyErrorTo(status);
}
};
} // namespace impl
/**
* An abstract base class for specifying settings related to number formatting. This class is implemented by
* {@link UnlocalizedNumberRangeFormatter} and {@link LocalizedNumberRangeFormatter}. This class is not intended for
* public subclassing.
*/
template<typename Derived>
class U_I18N_API NumberRangeFormatterSettings {
public:
/**
* Sets the NumberFormatter instance to use for the numbers in the range. The same formatter is applied to both
* sides of the range.
* <p>
* The NumberFormatter instances must not have a locale applied yet; the locale specified on the
* NumberRangeFormatter will be used.
*
* @param formatter
* The formatter to use for both numbers in the range.
* @return The fluent chain.
* @draft ICU 63
*/
Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) const &;
/**
* Overload of numberFormatterBoth() for use on an rvalue reference.
*
* @param formatter
* The formatter to use for both numbers in the range.
* @return The fluent chain.
* @see #numberFormatterBoth
* @draft ICU 63
*/
Derived numberFormatterBoth(const UnlocalizedNumberFormatter &formatter) &&;
/**
* Overload of numberFormatterBoth() for use on an rvalue reference.
*
* @param formatter
* The formatter to use for both numbers in the range.
* @return The fluent chain.
* @see #numberFormatterBoth
* @draft ICU 63
*/
Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) const &;
/**
* Overload of numberFormatterBoth() for use on an rvalue reference.
*
* @param formatter
* The formatter to use for both numbers in the range.
* @return The fluent chain.
* @see #numberFormatterBoth
* @draft ICU 63
*/
Derived numberFormatterBoth(UnlocalizedNumberFormatter &&formatter) &&;
/**
* Sets the NumberFormatter instance to use for the first number in the range.
* <p>
* The NumberFormatter instances must not have a locale applied yet; the locale specified on the
* NumberRangeFormatter will be used.
*
* @param formatterFirst
* The formatter to use for the first number in the range.
* @return The fluent chain.
* @draft ICU 63
*/
Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) const &;
/**
* Overload of numberFormatterFirst() for use on an rvalue reference.
*
* @param formatterFirst
* The formatter to use for the first number in the range.
* @return The fluent chain.
* @see #numberFormatterFirst
* @draft ICU 63
*/
Derived numberFormatterFirst(const UnlocalizedNumberFormatter &formatterFirst) &&;
/**
* Overload of numberFormatterFirst() for use on an rvalue reference.
*
* @param formatterFirst
* The formatter to use for the first number in the range.
* @return The fluent chain.
* @see #numberFormatterFirst
* @draft ICU 63
*/
Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) const &;
/**
* Overload of numberFormatterFirst() for use on an rvalue reference.
*
* @param formatterFirst
* The formatter to use for the first number in the range.
* @return The fluent chain.
* @see #numberFormatterFirst
* @draft ICU 63
*/
Derived numberFormatterFirst(UnlocalizedNumberFormatter &&formatterFirst) &&;
/**
* Sets the NumberFormatter instance to use for the second number in the range.
* <p>
* The NumberFormatter instances must not have a locale applied yet; the locale specified on the
* NumberRangeFormatter will be used.
*
* @param formatterSecond
* The formatter to use for the second number in the range.
* @return The fluent chain.
* @draft ICU 63
*/
Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) const &;
/**
* Overload of numberFormatterSecond() for use on an rvalue reference.
*
* @param formatterSecond
* The formatter to use for the second number in the range.
* @return The fluent chain.
* @see #numberFormatterSecond
* @draft ICU 63
*/
Derived numberFormatterSecond(const UnlocalizedNumberFormatter &formatterSecond) &&;
/**
* Overload of numberFormatterSecond() for use on an rvalue reference.
*
* @param formatterSecond
* The formatter to use for the second number in the range.
* @return The fluent chain.
* @see #numberFormatterSecond
* @draft ICU 63
*/
Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) const &;
/**
* Overload of numberFormatterSecond() for use on an rvalue reference.
*
* @param formatterSecond
* The formatter to use for the second number in the range.
* @return The fluent chain.
* @see #numberFormatterSecond
* @draft ICU 63
*/
Derived numberFormatterSecond(UnlocalizedNumberFormatter &&formatterSecond) &&;
/**
* Sets the aggressiveness of "collapsing" fields across the range separator. Possible values:
* <p>
* <ul>
* <li>ALL: "3-5K miles"</li>
* <li>UNIT: "3K - 5K miles"</li>
* <li>NONE: "3K miles - 5K miles"</li>
* <li>AUTO: usually UNIT or NONE, depending on the locale and formatter settings</li>
* </ul>
* <p>
* The default value is AUTO.
*
* @param collapse
* The collapsing strategy to use for this range.
* @return The fluent chain.
* @draft ICU 63
*/
Derived collapse(UNumberRangeCollapse collapse) const &;
/**
* Overload of collapse() for use on an rvalue reference.
*
* @param collapse
* The collapsing strategy to use for this range.
* @return The fluent chain.
* @see #collapse
* @draft ICU 63
*/
Derived collapse(UNumberRangeCollapse collapse) &&;
/**
* Sets the behavior when the two sides of the range are the same. This could happen if the same two numbers are
* passed to the formatRange function, or if different numbers are passed to the function but they become the same
* after rounding rules are applied. Possible values:
* <p>
* <ul>
* <li>SINGLE_VALUE: "5 miles"</li>
* <li>APPROXIMATELY_OR_SINGLE_VALUE: "~5 miles" or "5 miles", depending on whether the number was the same before
* rounding was applied</li>
* <li>APPROXIMATELY: "~5 miles"</li>
* <li>RANGE: "5-5 miles" (with collapse=UNIT)</li>
* </ul>
* <p>
* The default value is APPROXIMATELY.
*
* @param identityFallback
* The strategy to use when formatting two numbers that end up being the same.
* @return The fluent chain.
* @draft ICU 63
*/
Derived identityFallback(UNumberRangeIdentityFallback identityFallback) const &;
/**
* Overload of identityFallback() for use on an rvalue reference.
*
* @param identityFallback
* The strategy to use when formatting two numbers that end up being the same.
* @return The fluent chain.
* @see #identityFallback
* @draft ICU 63
*/
Derived identityFallback(UNumberRangeIdentityFallback identityFallback) &&;
/**
* Sets the UErrorCode if an error occurred in the fluent chain.
* Preserves older error codes in the outErrorCode.
* @return TRUE if U_FAILURE(outErrorCode)
* @draft ICU 63
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const {
if (U_FAILURE(outErrorCode)) {
// Do not overwrite the older error code
return TRUE;
}
fMacros.copyErrorTo(outErrorCode);
return U_FAILURE(outErrorCode);
};
// NOTE: Uses default copy and move constructors.
private:
impl::RangeMacroProps fMacros;
// Don't construct me directly! Use (Un)LocalizedNumberFormatter.
NumberRangeFormatterSettings() = default;
friend class LocalizedNumberRangeFormatter;
friend class UnlocalizedNumberRangeFormatter;
};
/**
* A NumberRangeFormatter that does not yet have a locale. In order to format, a locale must be specified.
*
* @see NumberRangeFormatter
* @draft ICU 63
*/
class U_I18N_API UnlocalizedNumberRangeFormatter
: public NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>, public UMemory {
public:
/**
* Associate the given locale with the number range formatter. The locale is used for picking the
* appropriate symbols, formats, and other data for number display.
*
* @param locale
* The locale to use when loading data for number formatting.
* @return The fluent chain.
* @draft ICU 63
*/
LocalizedNumberRangeFormatter locale(const icu::Locale &locale) const &;
/**
* Overload of locale() for use on an rvalue reference.
*
* @param locale
* The locale to use when loading data for number formatting.
* @return The fluent chain.
* @see #locale
* @draft ICU 63
*/
LocalizedNumberRangeFormatter locale(const icu::Locale &locale) &&;
/**
* Default constructor: puts the formatter into a valid but undefined state.
*
* @draft ICU 63
*/
UnlocalizedNumberRangeFormatter() = default;
/**
* Returns a copy of this UnlocalizedNumberRangeFormatter.
* @draft ICU 63
*/
UnlocalizedNumberRangeFormatter(const UnlocalizedNumberRangeFormatter &other);
/**
* Move constructor:
* The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state.
* @draft ICU 63
*/
UnlocalizedNumberRangeFormatter(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT;
/**
* Copy assignment operator.
* @draft ICU 63
*/
UnlocalizedNumberRangeFormatter& operator=(const UnlocalizedNumberRangeFormatter& other);
/**
* Move assignment operator:
* The source UnlocalizedNumberRangeFormatter will be left in a valid but undefined state.
* @draft ICU 63
*/
UnlocalizedNumberRangeFormatter& operator=(UnlocalizedNumberRangeFormatter&& src) U_NOEXCEPT;
private:
explicit UnlocalizedNumberRangeFormatter(
const NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>& other);
explicit UnlocalizedNumberRangeFormatter(
NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>&& src) U_NOEXCEPT;
// To give the fluent setters access to this class's constructor:
friend class NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>;
// To give NumberRangeFormatter::with() access to this class's constructor:
friend class NumberRangeFormatter;
};
/**
* A NumberRangeFormatter that has a locale associated with it; this means .formatRange() methods are available.
*
* @see NumberFormatter
* @draft ICU 63
*/
class U_I18N_API LocalizedNumberRangeFormatter
: public NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>, public UMemory {
public:
/**
* Format the given Formattables to a string using the settings specified in the NumberRangeFormatter fluent setting
* chain.
*
* @param first
* The first number in the range, usually to the left in LTR locales.
* @param second
* The second number in the range, usually to the right in LTR locales.
* @param status
* Set if an error occurs while formatting.
* @return A FormattedNumberRange object; call .toString() to get the string.
* @draft ICU 63
*/
FormattedNumberRange formatFormattableRange(
const Formattable& first, const Formattable& second, UErrorCode& status) const;
/**
* Default constructor: puts the formatter into a valid but undefined state.
*
* @draft ICU 63
*/
LocalizedNumberRangeFormatter() = default;
/**
* Returns a copy of this LocalizedNumberRangeFormatter.
* @draft ICU 63
*/
LocalizedNumberRangeFormatter(const LocalizedNumberRangeFormatter &other);
/**
* Move constructor:
* The source LocalizedNumberRangeFormatter will be left in a valid but undefined state.
* @draft ICU 63
*/
LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT;
/**
* Copy assignment operator.
* @draft ICU 63
*/
LocalizedNumberRangeFormatter& operator=(const LocalizedNumberRangeFormatter& other);
/**
* Move assignment operator:
* The source LocalizedNumberRangeFormatter will be left in a valid but undefined state.
* @draft ICU 63
*/
LocalizedNumberRangeFormatter& operator=(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT;
#ifndef U_HIDE_INTERNAL_API
/**
* @param results
* The results object. This method will mutate it to save the results.
* @param equalBeforeRounding
* Whether the number was equal before copying it into a DecimalQuantity.
* Used for determining the identity fallback behavior.
* @param status
* Set if an error occurs while formatting.
* @internal
*/
void formatImpl(impl::UFormattedNumberRangeData& results, bool equalBeforeRounding,
UErrorCode& status) const;
#endif
/**
* Destruct this LocalizedNumberRangeFormatter, cleaning up any memory it might own.
* @draft ICU 63
*/
~LocalizedNumberRangeFormatter();
private:
std::atomic<impl::NumberRangeFormatterImpl*> fAtomicFormatter = {};
const impl::NumberRangeFormatterImpl* getFormatter(UErrorCode& stauts) const;
explicit LocalizedNumberRangeFormatter(
const NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>& other);
explicit LocalizedNumberRangeFormatter(
NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>&& src) U_NOEXCEPT;
LocalizedNumberRangeFormatter(const impl::RangeMacroProps &macros, const Locale &locale);
LocalizedNumberRangeFormatter(impl::RangeMacroProps &&macros, const Locale &locale);
void clear();
// To give the fluent setters access to this class's constructor:
friend class NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter>;
friend class NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>;
// To give UnlocalizedNumberRangeFormatter::locale() access to this class's constructor:
friend class UnlocalizedNumberRangeFormatter;
};
/**
* The result of a number range formatting operation. This class allows the result to be exported in several data types,
* including a UnicodeString and a FieldPositionIterator.
*
* @draft ICU 63
*/
class U_I18N_API FormattedNumberRange : public UMemory {
public:
/**
* Returns a UnicodeString representation of the formatted number range.
*
* @param status
* Set if an error occurs while formatting the number to the UnicodeString.
* @return a UnicodeString containing the localized number range.
* @draft ICU 63
*/
UnicodeString toString(UErrorCode& status) const;
/**
* Appends the formatted number range to an Appendable.
*
* @param appendable
* The Appendable to which to append the formatted number range string.
* @param status
* Set if an error occurs while formatting the number range to the Appendable.
* @return The same Appendable, for chaining.
* @draft ICU 63
* @see Appendable
*/
Appendable &appendTo(Appendable &appendable, UErrorCode& status) const;
/**
* Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given
* <em>field</em> in the output string. This allows you to determine the locations of, for example,
* the integer part, fraction part, or symbols.
*
* If both sides of the range have the same field, the field will occur twice, once before the
* range separator and once after the range separator, if applicable.
*
* If a field occurs just once, calling this method will find that occurrence and return it. If a
* field occurs multiple times, this method may be called repeatedly with the following pattern:
*
* <pre>
* FieldPosition fpos(UNUM_INTEGER_FIELD);
* while (formattedNumberRange.nextFieldPosition(fpos, status)) {
* // do something with fpos.
* }
* </pre>
*
* This method is useful if you know which field to query. If you want all available field position
* information, use #getAllFieldPositions().
*
* @param fieldPosition
* Input+output variable. See {@link FormattedNumber#nextFieldPosition}.
* @param status
* Set if an error occurs while populating the FieldPosition.
* @return TRUE if a new occurrence of the field was found; FALSE otherwise.
* @draft ICU 63
* @see UNumberFormatFields
*/
UBool nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const;
/**
* Export the formatted number range to a FieldPositionIterator. This allows you to determine which characters in
* the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
*
* If information on only one field is needed, use #nextFieldPosition() instead.
*
* @param iterator
* The FieldPositionIterator to populate with all of the fields present in the formatted number.
* @param status
* Set if an error occurs while populating the FieldPositionIterator.
* @draft ICU 63
* @see UNumberFormatFields
*/
void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const;
/**
* Export the first formatted number as a decimal number. This endpoint
* is useful for obtaining the exact number being printed after scaling
* and rounding have been applied by the number range formatting pipeline.
*
* The syntax of the unformatted number is a "numeric string"
* as defined in the Decimal Arithmetic Specification, available at
* http://speleotrove.com/decimal
*
* @return A decimal representation of the first formatted number.
* @draft ICU 63
* @see NumberRangeFormatter
* @see #getSecondDecimal
*/
UnicodeString getFirstDecimal(UErrorCode& status) const;
/**
* Export the second formatted number as a decimal number. This endpoint
* is useful for obtaining the exact number being printed after scaling
* and rounding have been applied by the number range formatting pipeline.
*
* The syntax of the unformatted number is a "numeric string"
* as defined in the Decimal Arithmetic Specification, available at
* http://speleotrove.com/decimal
*
* @return A decimal representation of the second formatted number.
* @draft ICU 63
* @see NumberRangeFormatter
* @see #getFirstDecimal
*/
UnicodeString getSecondDecimal(UErrorCode& status) const;
/**
* Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was
* used. For example, if the first and second number were the same either before or after rounding occurred, an
* identity fallback was used.
*
* @return An indication the resulting identity situation in the formatted number range.
* @draft ICU 63
* @see UNumberRangeIdentityFallback
*/
UNumberRangeIdentityResult getIdentityResult(UErrorCode& status) const;
/**
* Copying not supported; use move constructor instead.
*/
FormattedNumberRange(const FormattedNumberRange&) = delete;
/**
* Copying not supported; use move assignment instead.
*/
FormattedNumberRange& operator=(const FormattedNumberRange&) = delete;
/**
* Move constructor:
* Leaves the source FormattedNumberRange in an undefined state.
* @draft ICU 63
*/
FormattedNumberRange(FormattedNumberRange&& src) U_NOEXCEPT;
/**
* Move assignment:
* Leaves the source FormattedNumberRange in an undefined state.
* @draft ICU 63
*/
FormattedNumberRange& operator=(FormattedNumberRange&& src) U_NOEXCEPT;
/**
* Destruct an instance of FormattedNumberRange, cleaning up any memory it might own.
* @draft ICU 63
*/
~FormattedNumberRange();
private:
// Can't use LocalPointer because UFormattedNumberRangeData is forward-declared
const impl::UFormattedNumberRangeData *fResults;
// Error code for the terminal methods
UErrorCode fErrorCode;
/**
* Internal constructor from data type. Adopts the data pointer.
* @internal
*/
explicit FormattedNumberRange(impl::UFormattedNumberRangeData *results)
: fResults(results), fErrorCode(U_ZERO_ERROR) {};
explicit FormattedNumberRange(UErrorCode errorCode)
: fResults(nullptr), fErrorCode(errorCode) {};
void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
// To give LocalizedNumberRangeFormatter format methods access to this class's constructor:
friend class LocalizedNumberRangeFormatter;
};
/**
* See the main description in numberrangeformatter.h for documentation and examples.
*
* @draft ICU 63
*/
class U_I18N_API NumberRangeFormatter final {
public:
/**
* Call this method at the beginning of a NumberRangeFormatter fluent chain in which the locale is not currently
* known at the call site.
*
* @return An {@link UnlocalizedNumberRangeFormatter}, to be used for chaining.
* @draft ICU 63
*/
static UnlocalizedNumberRangeFormatter with();
/**
* Call this method at the beginning of a NumberRangeFormatter fluent chain in which the locale is known at the call
* site.
*
* @param locale
* The locale from which to load formats and symbols for number range formatting.
* @return A {@link LocalizedNumberRangeFormatter}, to be used for chaining.
* @draft ICU 63
*/
static LocalizedNumberRangeFormatter withLocale(const Locale &locale);
/**
* Use factory methods instead of the constructor to create a NumberFormatter.
*/
NumberRangeFormatter() = delete;
};
} // namespace number
U_NAMESPACE_END
#endif // U_HIDE_DRAFT_API
#endif // __NUMBERRANGEFORMATTER_H__
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -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,11 +53,15 @@ 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.
*
* 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.
*
* \headerfile unicode/numfmt.h "unicode/numfmt.h"
* <P>
* NumberFormat helps you to format and parse numbers for any locale.
@ -168,6 +172,33 @@ class StringEnumeration;
*/
class U_I18N_API NumberFormat : public Format {
public:
/**
* Rounding mode.
*
* <p>
* For more detail on rounding modes, see:
* http://userguide.icu-project.org/formatparse/numbers/rounding-modes
*
* @stable ICU 2.4
*/
enum ERoundingMode {
kRoundCeiling, /**< Round towards positive infinity */
kRoundFloor, /**< Round towards negative infinity */
kRoundDown, /**< Round towards zero */
kRoundUp, /**< Round away from zero */
kRoundHalfEven, /**< Round towards the nearest integer, or
towards the nearest even integer if equidistant */
kRoundHalfDown, /**< Round towards the nearest integer, or
towards zero if equidistant */
kRoundHalfUp, /**< Round towards the nearest integer, or
away from zero if equidistant */
/**
* Return U_FORMAT_INEXACT_ERROR if number does not format exactly.
* @stable ICU 4.8
*/
kRoundUnnecessary
};
/**
* Alignment Field constants used to construct a FieldPosition object.
* Signifies that the position of the integer part or fraction part of
@ -523,16 +554,18 @@ public:
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
public:
// Can't use #ifndef U_HIDE_INTERNAL_API because these are virtual methods
/**
* Format a decimal number.
* The number is a DigitList wrapper onto a floating point decimal number.
* The number is a DecimalQuantity wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that. Subclasses of NumberFormat that want
* to specifically handle big decimal numbers must override this method.
* class DecimalFormat does so.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param number The number, a DecimalQuantity format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
@ -541,20 +574,20 @@ public:
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const DigitList &number,
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a decimal number.
* The number is a DigitList wrapper onto a floating point decimal number.
* The number is a DecimalQuantity wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that. Subclasses of NumberFormat that want
* to specifically handle big decimal numbers must override this method.
* class DecimalFormat does so.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param number The number, a DecimalQuantity format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
@ -563,13 +596,11 @@ public:
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const DigitList &number,
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
public:
/**
* Return a long if possible (e.g. within range LONG_MAX,
* LONG_MAX], and with no decimals), otherwise a double. If
@ -676,6 +707,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 icu::number::NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
@ -684,6 +718,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 icu::number::NumberFormatter} instead of NumberFormat.
* @stable ICU 2.0
*/
static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
@ -691,6 +728,9 @@ public:
/**
* Create a specific style NumberFormat for the specified locale.
* <p>
* <strong>NOTE:</strong> New users are strongly encouraged to use
* {@link icu::number::NumberFormatter} instead of NumberFormat.
* @param desiredLocale the given locale.
* @param style the given style.
* @param errorCode Output param filled with success/failure status.
@ -727,12 +767,18 @@ public:
/**
* Returns a currency format for the current default locale.
* <p>
* <strong>NOTE:</strong> New users are strongly encouraged to use
* {@link icu::number::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 icu::number::NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
@ -741,12 +787,18 @@ public:
/**
* Returns a percentage format for the current default locale.
* <p>
* <strong>NOTE:</strong> New users are strongly encouraged to use
* {@link icu::number::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 icu::number::NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
@ -755,12 +807,18 @@ public:
/**
* Returns a scientific format for the current default locale.
* <p>
* <strong>NOTE:</strong> New users are strongly encouraged to use
* {@link icu::number::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 icu::number::NumberFormatter} instead of NumberFormat.
* @param inLocale the given locale.
* @stable ICU 2.0
*/
@ -814,7 +872,7 @@ public:
* Returns true if grouping is used in this format. For example,
* in the English locale, with grouping on, the number 1234567
* might be formatted as "1,234,567". The grouping separator as
* well as the size of each group is locale dependant and is
* well as the size of each group is locale dependent and is
* determined by sub-classes of NumberFormat.
* @see setGroupingUsed
* @stable ICU 2.0
@ -931,7 +989,7 @@ public:
* @param ec input-output error code
* @stable ICU 3.0
*/
virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
/**
* Gets the currency used to display currency
@ -940,8 +998,8 @@ public:
* the currency in use, or a pointer to the empty string.
* @stable ICU 2.6
*/
const UChar* getCurrency() const;
const char16_t* getCurrency() const;
/**
* Set a particular UDisplayContext value in the formatter, such as
* UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
@ -965,6 +1023,21 @@ public:
*/
virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
/**
* Get the rounding mode. This will always return NumberFormat::ERoundingMode::kRoundUnnecessary
* if the subclass does not support rounding.
* @return A rounding mode
* @stable ICU 60
*/
virtual ERoundingMode getRoundingMode(void) const;
/**
* Set the rounding mode. If a subclass does not support rounding, this will do nothing.
* @param roundingMode A rounding mode
* @stable ICU 60
*/
virtual void setRoundingMode(ERoundingMode roundingMode);
public:
/**
@ -1018,7 +1091,7 @@ protected:
* have a capacity of at least 4
* @internal
*/
virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
#ifndef U_HIDE_INTERNAL_API
/**
@ -1065,7 +1138,7 @@ private:
UBool fLenient; // TRUE => lenient parse is enabled
// ISO currency code
UChar fCurrency[4];
char16_t fCurrency[4];
UDisplayContext fCapitalizationContext;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -193,7 +193,7 @@ private:
void setAlgorithmic(UBool algorithmic);
void setDesc(UnicodeString desc);
void setDesc(const UnicodeString &desc);
void setName(const char* name);

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -520,15 +520,7 @@ public:
*/
virtual UClassID getDynamicClassID() const;
#if (defined(__xlC__) && (__xlC__ < 0x0C00)) || (U_PLATFORM == U_PF_OS390) || (U_PLATFORM ==U_PF_OS400)
// Work around a compiler bug on xlC 11.1 on AIX 7.1 that would
// prevent PluralSelectorAdapter from implementing private PluralSelector.
// xlC error message:
// 1540-0300 (S) The "private" member "class icu_49::PluralFormat::PluralSelector" cannot be accessed.
public:
#else
private:
#endif
/**
* @internal
*/
@ -564,10 +556,6 @@ private:
PluralRules* pluralRules;
};
#if defined(__xlC__)
// End of xlC bug workaround, keep remaining definitions private.
private:
#endif
Locale locale;
MessagePattern msgPattern;
NumberFormat* numberFormat;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -29,6 +29,9 @@
#include "unicode/format.h"
#include "unicode/upluralrules.h"
#ifndef U_HIDE_INTERNAL_API
#include "unicode/numfmt.h"
#endif /* U_HIDE_INTERNAL_API */
/**
* Value returned by PluralRules::getUniqueKeywordValue() when there is no
@ -40,8 +43,7 @@
U_NAMESPACE_BEGIN
class Hashtable;
class FixedDecimal;
class VisibleDigitsWithExponent;
class IFixedDecimal;
class RuleChain;
class PluralRuleParser;
class PluralKeywordEnumeration;
@ -116,7 +118,6 @@ class SharedPluralRules;
* Examples are in the following table:
* </p>
* <table border='1' style="border-collapse:collapse">
* <tbody>
* <tr>
* <th>n</th>
* <th>i</th>
@ -153,7 +154,6 @@ class SharedPluralRules;
* <td align="right">23</td>
* <td>2</td>
* </tr>
* </tbody>
* </table>
* <p>
* The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within'
@ -348,11 +348,7 @@ public:
/**
* @internal
*/
UnicodeString select(const FixedDecimal &number) const;
/**
* @internal
*/
UnicodeString select(const VisibleDigitsWithExponent &number) const;
UnicodeString select(const IFixedDecimal &number) const;
#endif /* U_HIDE_INTERNAL_API */
/**
@ -383,7 +379,7 @@ public:
/**
* Deprecated Function, does not produce useful results.
*
* Orginally intended to return all the values for which select() would return the keyword.
* Originally intended to return all the values for which select() would return the keyword.
* If the keyword is unknown, returns no values, but this is not an error. If
* the number of values is unlimited, returns no values and -1 as the
* count.
@ -501,6 +497,12 @@ private:
UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
/**
* An internal status variable used to indicate that the object is in an 'invalid' state.
* Used by copy constructor, the assignment operator and the clone method.
*/
UErrorCode mInternalStatus;
friend class PluralRuleParser;
};

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -313,7 +313,6 @@ enum URBNFRuleSetTag {
* <td>The rule for an IEEE 754 NaN (not a number).</td>
* </tr>
* <tr>
* <tr>
* <td><em>nothing</em></td>
* <td>If the rule's rule descriptor is left out, the base value is one plus the
* preceding rule's base value (or zero if this is the first rule in the list) in a normal
@ -866,6 +865,52 @@ public:
FieldPosition& pos,
UErrorCode& status) const;
protected:
/**
* Format a decimal number.
* The number is a DigitList wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that. Subclasses of NumberFormat that want
* to specifically handle big decimal numbers must override this method.
* class DecimalFormat does so.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param posIter On return, can be used to iterate over positions
* of fields generated by this format call.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPositionIterator* posIter,
UErrorCode& status) const;
/**
* Format a decimal number.
* The number is a DigitList wrapper onto a floating point decimal number.
* The default implementation in NumberFormat converts the decimal number
* to a double and formats that. Subclasses of NumberFormat that want
* to specifically handle big decimal numbers must override this method.
* class DecimalFormat does so.
*
* @param number The number, a DigitList format Decimal Floating Point.
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param status Output param filled with success/failure status.
* @return Reference to 'appendTo' parameter.
* @internal
*/
virtual UnicodeString& format(const number::impl::DecimalQuantity &number,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
public:
using NumberFormat::parse;
/**
@ -964,6 +1009,20 @@ public:
*/
virtual void setContext(UDisplayContext value, UErrorCode& status);
/**
* Get the rounding mode.
* @return A rounding mode
* @stable ICU 60
*/
virtual ERoundingMode getRoundingMode(void) const;
/**
* Set the rounding mode.
* @param roundingMode A rounding mode
* @stable ICU 60
*/
virtual void setRoundingMode(ERoundingMode roundingMode);
public:
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
@ -1013,7 +1072,6 @@ private:
void dispose();
void stripWhitespace(UnicodeString& src);
void initDefaultRuleSet();
void format(double number, NFRuleSet& ruleSet);
NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const;
/* friend access */
@ -1031,10 +1089,12 @@ private:
NFRule * initializeDefaultNaNRule(UErrorCode &status);
const NFRule * getDefaultNaNRule() const;
PluralFormat *createPluralFormat(UPluralType pluralType, const UnicodeString &pattern, UErrorCode& status) const;
UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult) const;
UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult, UErrorCode& status) const;
UnicodeString& format(int64_t number, NFRuleSet *ruleSet, UnicodeString& toAppendTo, UErrorCode& status) const;
void format(double number, NFRuleSet& rs, UnicodeString& toAppendTo, UErrorCode& status) const;
private:
NFRuleSet **ruleSets;
NFRuleSet **fRuleSets;
UnicodeString* ruleSetDescriptions;
int32_t numRuleSets;
NFRuleSet *defaultRuleSet;
@ -1043,6 +1103,7 @@ private:
DecimalFormatSymbols* decimalFormatSymbols;
NFRule *defaultInfinityRule;
NFRule *defaultNaNRule;
ERoundingMode fRoundingMode;
UBool lenient;
UnicodeString* lenientParseRules;
LocalizationInfo* localizations;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -6,7 +6,7 @@
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: regex.h
* encoding: US-ASCII
* encoding: UTF-8
* indentation:4
*
* created on: 2002oct22
@ -350,17 +350,17 @@ public:
private:
/**
* Cause a compilation error if an application accidentally attempts to
* create a matcher with a (UChar *) string as input rather than
* create a matcher with a (char16_t *) string as input rather than
* a UnicodeString. Avoids a dangling reference to a temporary string.
* <p>
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
* using one of the aliasing constructors, such as
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
* or in a UText, using
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
*
*/
RegexMatcher *matcher(const UChar *input,
RegexMatcher *matcher(const char16_t *input,
UErrorCode &status) const;
public:
@ -748,17 +748,17 @@ public:
private:
/**
* Cause a compilation error if an application accidentally attempts to
* create a matcher with a (UChar *) string as input rather than
* create a matcher with a (char16_t *) string as input rather than
* a UnicodeString. Avoids a dangling reference to a temporary string.
* <p>
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
* using one of the aliasing constructors, such as
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
* or in a UText, using
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
*
*/
RegexMatcher(const UnicodeString &regexp, const UChar *input,
RegexMatcher(const UnicodeString &regexp, const char16_t *input,
uint32_t flags, UErrorCode &status);
public:
@ -1156,17 +1156,17 @@ public:
private:
/**
* Cause a compilation error if an application accidentally attempts to
* reset a matcher with a (UChar *) string as input rather than
* reset a matcher with a (char16_t *) string as input rather than
* a UnicodeString. Avoids a dangling reference to a temporary string.
* <p>
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
* using one of the aliasing constructors, such as
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
* or in a UText, using
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
*
*/
RegexMatcher &reset(const UChar *input);
RegexMatcher &reset(const char16_t *input);
public:
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -192,7 +192,7 @@ private:
char id[4];
UnicodeString idStr;
int32_t code;
URegionType type;
URegionType fType;
Region *containingRegion;
UVector *containedRegions;
UVector *preferredValues;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************
@ -165,12 +165,20 @@ typedef enum UDateAbsoluteUnit {
*/
UDAT_ABSOLUTE_NOW,
#ifndef U_HIDE_DRAFT_API
/**
* Quarter
* @draft ICU 63
*/
UDAT_ABSOLUTE_QUARTER,
#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_DEPRECATED_API
/**
* One more than the highest normal UDateAbsoluteUnit value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UDAT_ABSOLUTE_UNIT_COUNT
UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 2
#endif // U_HIDE_DEPRECATED_API
} UDateAbsoluteUnit;
@ -230,6 +238,7 @@ typedef enum UDateDirection {
U_NAMESPACE_BEGIN
class BreakIterator;
class RelativeDateTimeCacheData;
class SharedNumberFormat;
class SharedPluralRules;
@ -327,7 +336,7 @@ public:
* @param nfToAdopt Constructed object takes ownership of this pointer.
* It is an error for caller to delete this pointer or change its
* contents after calling this constructor.
* @status Any error is returned here.
* @param status Any error is returned here.
* @stable ICU 53
*/
RelativeDateTimeFormatter(
@ -345,7 +354,7 @@ public:
* @param style the format style. The UDAT_RELATIVE bit field has no effect.
* @param capitalizationContext A value from UDisplayContext that pertains to
* capitalization.
* @status Any error is returned here.
* @param status Any error is returned here.
* @stable ICU 54
*/
RelativeDateTimeFormatter(
@ -414,7 +423,6 @@ public:
UnicodeString& appendTo,
UErrorCode& status) const;
#ifndef U_HIDE_DRAFT_API
/**
* Format a combination of URelativeDateTimeUnit and numeric offset
* using a numeric style, e.g. "1 week ago", "in 1 week",
@ -430,7 +438,7 @@ public:
* appended.
* @param status ICU error code returned here.
* @return appendTo
* @draft ICU 57
* @stable ICU 57
*/
UnicodeString& formatNumeric(
double offset,
@ -453,14 +461,13 @@ public:
* appended.
* @param status ICU error code returned here.
* @return appendTo
* @draft ICU 57
* @stable ICU 57
*/
UnicodeString& format(
double offset,
URelativeDateTimeUnit unit,
UnicodeString& appendTo,
UErrorCode& status) const;
#endif /* U_HIDE_DRAFT_API */
/**
* Combines a relative date string and a time string in this object's

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -24,7 +24,6 @@
U_NAMESPACE_BEGIN
class FieldPositionIterator;
class DecimalFormatStaticSets;
class DecimalFormatSymbols;
class DecimalFormat;
class Formattable;
@ -150,7 +149,6 @@ public:
const UnicodeString &original,
FieldPositionIterator &fpi,
const UnicodeString &preExponent,
const DecimalFormatStaticSets &decimalFormatSets,
UnicodeString &appendTo,
UErrorCode &status) const = 0;
private:
@ -165,7 +163,6 @@ public:
const UnicodeString &original,
FieldPositionIterator &fpi,
const UnicodeString &preExponent,
const DecimalFormatStaticSets &decimalFormatSets,
UnicodeString &appendTo,
UErrorCode &status) const;
};
@ -184,7 +181,6 @@ public:
const UnicodeString &original,
FieldPositionIterator &fpi,
const UnicodeString &preExponent,
const DecimalFormatStaticSets &decimalFormatSets,
UnicodeString &appendTo,
UErrorCode &status) const;
private:
@ -211,7 +207,6 @@ public:
UnicodeString fPreExponent;
DecimalFormat *fDecimalFormat;
Style *fStyle;
const DecimalFormatStaticSets *fStaticSets;
};

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -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;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
* Copyright (C) 1997-2016, International Business Machines Corporation and
@ -50,6 +50,10 @@ class TimeZoneFormat;
class SharedNumberFormat;
class SimpleDateFormatMutableNFs;
namespace number {
class LocalizedNumberFormatter;
}
/**
*
* SimpleDateFormat is a concrete class for formatting and parsing dates in a
@ -1143,7 +1147,7 @@ public:
* Overrides base class method and
* This method clears per field NumberFormat instances
* previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFormat*, UErrorCode)}
* @param adoptNF the NumbeferFormat used
* @param formatToAdopt the NumbeferFormat used
* @stable ICU 54
*/
void adoptNumberFormat(NumberFormat *formatToAdopt);
@ -1158,7 +1162,7 @@ public:
* Per field NumberFormat can also be cleared in {@see DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)}
*
* @param fields the fields to override(like y)
* @param adoptNF the NumbeferFormat used
* @param formatToAdopt the NumbeferFormat used
* @param status Receives a status code, which will be U_ZERO_ERROR
* if the operation succeeds.
* @stable ICU 54
@ -1170,7 +1174,7 @@ public:
* @param field The UDateFormatField to get
* @stable ICU 54
*/
const NumberFormat * getNumberFormatForField(UChar field) const;
const NumberFormat * getNumberFormatForField(char16_t field) const;
#ifndef U_HIDE_INTERNAL_API
/**
@ -1262,13 +1266,12 @@ private:
* succeeds.
*/
void subFormat(UnicodeString &appendTo,
UChar ch,
char16_t ch,
int32_t count,
UDisplayContext capitalizationContext,
int32_t fieldNum,
FieldPositionHandler& handler,
Calendar& cal,
SimpleDateFormatMutableNFs &mutableNFs,
UErrorCode& status) const; // in case of illegal argument
/**
@ -1284,7 +1287,7 @@ private:
* @param minDigits Minimum number of digits the result should have
* @param maxDigits Maximum number of digits the result should have
*/
void zeroPaddingNumber(NumberFormat *currentNumberFormat,
void zeroPaddingNumber(const NumberFormat *currentNumberFormat,
UnicodeString &appendTo,
int32_t value,
int32_t minDigits,
@ -1294,7 +1297,7 @@ private:
* Return true if the given format character, occuring count
* times, represents a numeric field.
*/
static UBool isNumeric(UChar formatChar, int32_t count);
static UBool isNumeric(char16_t formatChar, int32_t count);
/**
* Returns TRUE if the patternOffset is at the start of a numeric field.
@ -1412,27 +1415,37 @@ private:
* @return the new start position if matching succeeded; a negative number
* indicating matching failure, otherwise.
*/
int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
int32_t subParse(const UnicodeString& text, int32_t& start, char16_t ch, int32_t count,
UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType, SimpleDateFormatMutableNFs &mutableNFs,
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType,
int32_t *dayPeriod=NULL) const;
void parseInt(const UnicodeString& text,
Formattable& number,
ParsePosition& pos,
UBool allowNegative,
NumberFormat *fmt) const;
const NumberFormat *fmt) const;
void parseInt(const UnicodeString& text,
Formattable& number,
int32_t maxDigits,
ParsePosition& pos,
UBool allowNegative,
NumberFormat *fmt) const;
const NumberFormat *fmt) const;
int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
int32_t patLoc, UBool isNegative) const;
/**
* Counts number of digit code points in the specified text.
*
* @param text input text
* @param start start index, inclusive
* @param end end index, exclusive
* @return number of digits found in the text in the specified range.
*/
int32_t countDigits(const UnicodeString& text, int32_t start, int32_t end) const;
/**
* Translate a pattern, mapping each character in the from string to the
* corresponding character in the to string. Return an error if the original
@ -1485,6 +1498,16 @@ private:
*/
int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos) const;
/**
* Initialize LocalizedNumberFormatter instances used for speedup.
*/
void initFastNumberFormatters(UErrorCode& status);
/**
* Delete the LocalizedNumberFormatter instances used for speedup.
*/
void freeFastNumberFormatters();
/**
* Initialize NumberFormat instances used for numbering system overrides.
*/
@ -1508,7 +1531,7 @@ private:
/**
* Lazy TimeZoneFormat instantiation, semantically const
*/
TimeZoneFormat *tzFormat() const;
TimeZoneFormat *tzFormat(UErrorCode &status) const;
const NumberFormat* getNumberFormatByIndex(UDateFormatField index) const;
@ -1523,12 +1546,12 @@ private:
/**
* Map calendar field letter into calendar field level.
*/
static int32_t getLevelFromChar(UChar ch);
static int32_t getLevelFromChar(char16_t ch);
/**
* Tell if a character can be used to define a field in a format string.
*/
static UBool isSyntaxChar(UChar ch);
static UBool isSyntaxChar(char16_t ch);
/**
* The formatting pattern for this formatter.
@ -1601,6 +1624,20 @@ private:
*/
const SharedNumberFormat **fSharedNumberFormatters;
enum NumberFormatterKey {
SMPDTFMT_NF_1x10,
SMPDTFMT_NF_2x10,
SMPDTFMT_NF_3x10,
SMPDTFMT_NF_4x10,
SMPDTFMT_NF_2x2,
SMPDTFMT_NF_COUNT
};
/**
* Number formatters pre-allocated for fast performance on the most common integer lengths.
*/
const number::LocalizedNumberFormatter* fFastNumberFormatters[SMPDTFMT_NF_COUNT] = {};
UBool fHaveDefaultCentury;
BreakIterator* fCapitalizationBrkIter;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
@ -308,8 +308,8 @@ public:
* than target
* @stable ICU 2.6
*/
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
const UChar* target, int32_t targetLength,
virtual UCollationResult compare(const char16_t* source, int32_t sourceLength,
const char16_t* target, int32_t targetLength,
UErrorCode &status) const;
/**
@ -377,7 +377,7 @@ public:
* @see CollationKey
* @stable ICU 2.0
*/
virtual CollationKey& getCollationKey(const UChar *source,
virtual CollationKey& getCollationKey(const char16_t *source,
int32_t sourceLength,
CollationKey& key,
UErrorCode& status) const;
@ -552,7 +552,7 @@ public:
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See setMaxVariable().
* @param varTop one or more (if contraction) UChars to which the variable top should be set
* @param varTop one or more (if contraction) char16_ts to which the variable top should be set
* @param len length of variable top string. If -1 it is considered to be zero terminated.
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
@ -561,7 +561,7 @@ public:
* @return variable top primary weight
* @deprecated ICU 53 Call setMaxVariable() instead.
*/
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status);
virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status);
/**
* Sets the variable top to the primary weight of the specified string.
@ -570,7 +570,7 @@ public:
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See setMaxVariable().
* @param varTop a UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
* @param varTop a UnicodeString size 1 or more (if contraction) of char16_ts to which the variable top should be set
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
@ -631,7 +631,7 @@ public:
int32_t resultLength) const;
/**
* Get the sort key as an array of bytes from a UChar buffer.
* Get the sort key as an array of bytes from a char16_t buffer.
*
* Note that sort keys are often less efficient than simply doing comparison.
* For more details, see the ICU User Guide.
@ -646,7 +646,7 @@ public:
* @return Number of bytes needed for storing the sort key
* @stable ICU 2.2
*/
virtual int32_t getSortKey(const UChar *source, int32_t sourceLength,
virtual int32_t getSortKey(const char16_t *source, int32_t sourceLength,
uint8_t *result, int32_t resultLength) const;
/**
@ -821,17 +821,17 @@ private:
void adoptTailoring(CollationTailoring *t, UErrorCode &errorCode);
// Both lengths must be <0 or else both must be >=0.
UCollationResult doCompare(const UChar *left, int32_t leftLength,
const UChar *right, int32_t rightLength,
UCollationResult doCompare(const char16_t *left, int32_t leftLength,
const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const;
UCollationResult doCompare(const uint8_t *left, int32_t leftLength,
const uint8_t *right, int32_t rightLength,
UErrorCode &errorCode) const;
void writeSortKey(const UChar *s, int32_t length,
void writeSortKey(const char16_t *s, int32_t length,
SortKeyByteSink &sink, UErrorCode &errorCode) const;
void writeIdenticalLevel(const UChar *s, const UChar *limit,
void writeIdenticalLevel(const char16_t *s, const char16_t *limit,
SortKeyByteSink &sink, UErrorCode &errorCode) const;
const CollationSettings &getDefaultSettings() const;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*************************************************************************
* Copyright (c) 1997-2016, International Business Machines Corporation
@ -284,6 +284,8 @@ public:
* and may return a different TimeZone from the one returned by
* TimeZone::createDefault().
*
* <p>This function is not thread safe.</p>
*
* @return A new instance of TimeZone detected from the current host system
* configuration.
* @stable ICU 55
@ -866,7 +868,7 @@ private:
* @param id zone id string
* @return the pointer of the ID resource, or NULL.
*/
static const UChar* findID(const UnicodeString& id);
static const char16_t* findID(const UnicodeString& id);
/**
* Resolve a link in Olson tzdata. When the given id is known and it's not a link,
@ -876,7 +878,7 @@ private:
* @param id zone id string
* @return the dereferenced zone or NULL
*/
static const UChar* dereferOlsonLink(const UnicodeString& id);
static const char16_t* dereferOlsonLink(const UnicodeString& id);
/**
* Returns the region code associated with the given zone,
@ -884,7 +886,7 @@ private:
* @param id zone id string
* @return the region associated with the given zone
*/
static const UChar* getRegion(const UnicodeString& id);
static const char16_t* getRegion(const UnicodeString& id);
public:
#ifndef U_HIDE_INTERNAL_API
@ -896,7 +898,7 @@ private:
* @return the region associated with the given zone
* @internal
*/
static const UChar* getRegion(const UnicodeString& id, UErrorCode& status);
static const char16_t* getRegion(const UnicodeString& id, UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
private:

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -15,10 +15,10 @@
#include "unicode/utypes.h"
/**
* \file
* \file
* \brief C++ API: Tranforms text from one format to another.
*/
#if !UCONFIG_NO_TRANSLITERATION
#include "unicode/uobject.h"
@ -31,7 +31,6 @@ U_NAMESPACE_BEGIN
class UnicodeFilter;
class UnicodeSet;
class CompoundTransliterator;
class TransliteratorParser;
class NormalizationTransliterator;
class TransliteratorIDParser;
@ -77,8 +76,7 @@ class TransliteratorIDParser;
* transliteration. For example, given a string <code>input</code>
* and a transliterator <code>t</code>, the call
*
* \htmlonly<blockquote>\endhtmlonly<code>String result = t.transliterate(input);
* </code>\htmlonly</blockquote>\endhtmlonly
* String result = t.transliterate(input);
*
* will transliterate it and return the result. Other methods allow
* the client to specify a substring to be transliterated and to use
@ -98,22 +96,20 @@ class TransliteratorIDParser;
* contents of the buffer may show text being modified as each new
* character arrives.
*
* <p>Consider the simple <code>RuleBasedTransliterator</code>:
*
* \htmlonly<blockquote>\endhtmlonly<code>
* th&gt;{theta}<br>
* t&gt;{tau}
* </code>\htmlonly</blockquote>\endhtmlonly
* <p>Consider the simple rule-based Transliterator:
* <pre>
* th>{theta}
* t>{tau}
* </pre>
*
* When the user types 't', nothing will happen, since the
* transliterator is waiting to see if the next character is 'h'. To
* remedy this, we introduce the notion of a cursor, marked by a '|'
* in the output string:
*
* \htmlonly<blockquote>\endhtmlonly<code>
* t&gt;|{tau}<br>
* {tau}h&gt;{theta}
* </code>\htmlonly</blockquote>\endhtmlonly
* <pre>
* t>|{tau}
* {tau}h>{theta}
* </pre>
*
* Now when the user types 't', tau appears, and if the next character
* is 'h', the tau changes to a theta. This is accomplished by
@ -135,7 +131,7 @@ class TransliteratorIDParser;
* which the transliterator last stopped, either because it reached
* the end, or because it required more characters to disambiguate
* between possible inputs. The <code>CURSOR</code> can also be
* explicitly set by rules in a <code>RuleBasedTransliterator</code>.
* explicitly set by rules in a rule-based Transliterator.
* Any characters before the <code>CURSOR</code> index are frozen;
* future keyboard transliteration calls within this input sequence
* will not change them. New text is inserted at the
@ -237,6 +233,255 @@ class TransliteratorIDParser;
* if the performance of these methods can be improved over the
* performance obtained by the default implementations in this class.
*
* <p><b>Rule syntax</b>
*
* <p>A set of rules determines how to perform translations.
* Rules within a rule set are separated by semicolons (';').
* To include a literal semicolon, prefix it with a backslash ('\').
* Unicode Pattern_White_Space is ignored.
* If the first non-blank character on a line is '#',
* the entire line is ignored as a comment.
*
* <p>Each set of rules consists of two groups, one forward, and one
* reverse. This is a convention that is not enforced; rules for one
* direction may be omitted, with the result that translations in
* that direction will not modify the source text. In addition,
* bidirectional forward-reverse rules may be specified for
* symmetrical transformations.
*
* <p>Note: Another description of the Transliterator rule syntax is available in
* <a href="https://www.unicode.org/reports/tr35/tr35-general.html#Transform_Rules_Syntax">section
* Transform Rules Syntax of UTS #35: Unicode LDML</a>.
* The rules are shown there using arrow symbols and and .
* ICU supports both those and the equivalent ASCII symbols &lt; and &gt; and &lt;&gt;.
*
* <p>Rule statements take one of the following forms:
*
* <dl>
* <dt><code>$alefmadda=\\u0622;</code></dt>
* <dd><strong>Variable definition.</strong> The name on the
* left is assigned the text on the right. In this example,
* after this statement, instances of the left hand name,
* &quot;<code>$alefmadda</code>&quot;, will be replaced by
* the Unicode character U+0622. Variable names must begin
* with a letter and consist only of letters, digits, and
* underscores. Case is significant. Duplicate names cause
* an exception to be thrown, that is, variables cannot be
* redefined. The right hand side may contain well-formed
* text of any length, including no text at all (&quot;<code>$empty=;</code>&quot;).
* The right hand side may contain embedded <code>UnicodeSet</code>
* patterns, for example, &quot;<code>$softvowel=[eiyEIY]</code>&quot;.</dd>
* <dt><code>ai&gt;$alefmadda;</code></dt>
* <dd><strong>Forward translation rule.</strong> This rule
* states that the string on the left will be changed to the
* string on the right when performing forward
* transliteration.</dd>
* <dt><code>ai&lt;$alefmadda;</code></dt>
* <dd><strong>Reverse translation rule.</strong> This rule
* states that the string on the right will be changed to
* the string on the left when performing reverse
* transliteration.</dd>
* </dl>
*
* <dl>
* <dt><code>ai&lt;&gt;$alefmadda;</code></dt>
* <dd><strong>Bidirectional translation rule.</strong> This
* rule states that the string on the right will be changed
* to the string on the left when performing forward
* transliteration, and vice versa when performing reverse
* transliteration.</dd>
* </dl>
*
* <p>Translation rules consist of a <em>match pattern</em> and an <em>output
* string</em>. The match pattern consists of literal characters,
* optionally preceded by context, and optionally followed by
* context. Context characters, like literal pattern characters,
* must be matched in the text being transliterated. However, unlike
* literal pattern characters, they are not replaced by the output
* text. For example, the pattern &quot;<code>abc{def}</code>&quot;
* indicates the characters &quot;<code>def</code>&quot; must be
* preceded by &quot;<code>abc</code>&quot; for a successful match.
* If there is a successful match, &quot;<code>def</code>&quot; will
* be replaced, but not &quot;<code>abc</code>&quot;. The final '<code>}</code>'
* is optional, so &quot;<code>abc{def</code>&quot; is equivalent to
* &quot;<code>abc{def}</code>&quot;. Another example is &quot;<code>{123}456</code>&quot;
* (or &quot;<code>123}456</code>&quot;) in which the literal
* pattern &quot;<code>123</code>&quot; must be followed by &quot;<code>456</code>&quot;.
*
* <p>The output string of a forward or reverse rule consists of
* characters to replace the literal pattern characters. If the
* output string contains the character '<code>|</code>', this is
* taken to indicate the location of the <em>cursor</em> after
* replacement. The cursor is the point in the text at which the
* next replacement, if any, will be applied. The cursor is usually
* placed within the replacement text; however, it can actually be
* placed into the precending or following context by using the
* special character '@'. Examples:
*
* <pre>
* a {foo} z &gt; | @ bar; # foo -&gt; bar, move cursor before a
* {foo} xyz &gt; bar @@|; #&nbsp;foo -&gt; bar, cursor between y and z
* </pre>
*
* <p><b>UnicodeSet</b>
*
* <p><code>UnicodeSet</code> patterns may appear anywhere that
* makes sense. They may appear in variable definitions.
* Contrariwise, <code>UnicodeSet</code> patterns may themselves
* contain variable references, such as &quot;<code>$a=[a-z];$not_a=[^$a]</code>&quot;,
* or &quot;<code>$range=a-z;$ll=[$range]</code>&quot;.
*
* <p><code>UnicodeSet</code> patterns may also be embedded directly
* into rule strings. Thus, the following two rules are equivalent:
*
* <pre>
* $vowel=[aeiou]; $vowel&gt;'*'; # One way to do this
* [aeiou]&gt;'*'; # Another way
* </pre>
*
* <p>See {@link UnicodeSet} for more documentation and examples.
*
* <p><b>Segments</b>
*
* <p>Segments of the input string can be matched and copied to the
* output string. This makes certain sets of rules simpler and more
* general, and makes reordering possible. For example:
*
* <pre>
* ([a-z]) &gt; $1 $1; # double lowercase letters
* ([:Lu:]) ([:Ll:]) &gt; $2 $1; # reverse order of Lu-Ll pairs
* </pre>
*
* <p>The segment of the input string to be copied is delimited by
* &quot;<code>(</code>&quot; and &quot;<code>)</code>&quot;. Up to
* nine segments may be defined. Segments may not overlap. In the
* output string, &quot;<code>$1</code>&quot; through &quot;<code>$9</code>&quot;
* represent the input string segments, in left-to-right order of
* definition.
*
* <p><b>Anchors</b>
*
* <p>Patterns can be anchored to the beginning or the end of the text. This is done with the
* special characters '<code>^</code>' and '<code>$</code>'. For example:
*
* <pre>
* ^ a&nbsp;&nbsp; &gt; 'BEG_A'; &nbsp;&nbsp;# match 'a' at start of text
* &nbsp; a&nbsp;&nbsp; &gt; 'A'; # match other instances of 'a'
* &nbsp; z $ &gt; 'END_Z'; &nbsp;&nbsp;# match 'z' at end of text
* &nbsp; z&nbsp;&nbsp; &gt; 'Z';&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # match other instances of 'z'
* </pre>
*
* <p>It is also possible to match the beginning or the end of the text using a <code>UnicodeSet</code>.
* This is done by including a virtual anchor character '<code>$</code>' at the end of the
* set pattern. Although this is usually the match chafacter for the end anchor, the set will
* match either the beginning or the end of the text, depending on its placement. For
* example:
*
* <pre>
* $x = [a-z$]; &nbsp;&nbsp;# match 'a' through 'z' OR anchor
* $x 1&nbsp;&nbsp;&nbsp; &gt; 2;&nbsp;&nbsp; # match '1' after a-z or at the start
* &nbsp;&nbsp; 3 $x &gt; 4; &nbsp;&nbsp;# match '3' before a-z or at the end
* </pre>
*
* <p><b>Example</b>
*
* <p>The following example rules illustrate many of the features of
* the rule language.
*
* <table border="0" cellpadding="4">
* <tr>
* <td style="vertical-align: top;">Rule 1.</td>
* <td style="vertical-align: top; write-space: nowrap;"><code>abc{def}&gt;x|y</code></td>
* </tr>
* <tr>
* <td style="vertical-align: top;">Rule 2.</td>
* <td style="vertical-align: top; write-space: nowrap;"><code>xyz&gt;r</code></td>
* </tr>
* <tr>
* <td style="vertical-align: top;">Rule 3.</td>
* <td style="vertical-align: top; write-space: nowrap;"><code>yz&gt;q</code></td>
* </tr>
* </table>
*
* <p>Applying these rules to the string &quot;<code>adefabcdefz</code>&quot;
* yields the following results:
*
* <table border="0" cellpadding="4">
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>|adefabcdefz</code></td>
* <td style="vertical-align: top;">Initial state, no rules match. Advance
* cursor.</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>a|defabcdefz</code></td>
* <td style="vertical-align: top;">Still no match. Rule 1 does not match
* because the preceding context is not present.</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>ad|efabcdefz</code></td>
* <td style="vertical-align: top;">Still no match. Keep advancing until
* there is a match...</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>ade|fabcdefz</code></td>
* <td style="vertical-align: top;">...</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adef|abcdefz</code></td>
* <td style="vertical-align: top;">...</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adefa|bcdefz</code></td>
* <td style="vertical-align: top;">...</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adefab|cdefz</code></td>
* <td style="vertical-align: top;">...</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adefabc|defz</code></td>
* <td style="vertical-align: top;">Rule 1 matches; replace &quot;<code>def</code>&quot;
* with &quot;<code>xy</code>&quot; and back up the cursor
* to before the '<code>y</code>'.</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adefabcx|yz</code></td>
* <td style="vertical-align: top;">Although &quot;<code>xyz</code>&quot; is
* present, rule 2 does not match because the cursor is
* before the '<code>y</code>', not before the '<code>x</code>'.
* Rule 3 does match. Replace &quot;<code>yz</code>&quot;
* with &quot;<code>q</code>&quot;.</td>
* </tr>
* <tr>
* <td style="vertical-align: top; write-space: nowrap;"><code>adefabcxq|</code></td>
* <td style="vertical-align: top;">The cursor is at the end;
* transliteration is complete.</td>
* </tr>
* </table>
*
* <p>The order of rules is significant. If multiple rules may match
* at some point, the first matching rule is applied.
*
* <p>Forward and reverse rules may have an empty output string.
* Otherwise, an empty left or right hand side of any statement is a
* syntax error.
*
* <p>Single quotes are used to quote any character other than a
* digit or letter. To specify a single quote itself, inside or
* outside of quotes, use two single quotes in a row. For example,
* the rule &quot;<code>'&gt;'&gt;o''clock</code>&quot; changes the
* string &quot;<code>&gt;</code>&quot; to the string &quot;<code>o'clock</code>&quot;.
*
* <p><b>Notes</b>
*
* <p>While a Transliterator is being built from rules, it checks that
* the rules are added in proper order. For example, if the rule
* &quot;a&gt;x&quot; is followed by the rule &quot;ab&gt;y&quot;,
* then the second rule will throw an exception. The reason is that
* the second rule can never be triggered, since the first rule
* always matches anything it matches. In other words, the first
* rule <em>masks</em> the second rule.
*
* @author Alan Liu
* @stable ICU 2.0
*/
@ -499,9 +744,9 @@ public:
* for details.
* @param text the buffer holding transliterated and
* untransliterated text
* @param index an array of three integers. See {@link #transliterate(Replaceable&, UTransPosition&, const UnicodeString*, UErrorCode&) const }.
* @param index an array of three integers.
* @param status Output param to filled in with a success or an error.
* @see #transliterate(Replaceable, int[], String)
* @see #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode &) const
* @stable ICU 2.0
*/
virtual void transliterate(Replaceable& text, UTransPosition& index,
@ -632,7 +877,7 @@ public:
/**
* Transliterate a substring of text, as specified by index, taking filters
* into account. This method is for subclasses that need to delegate to
* another transliterator, such as CompoundTransliterator.
* another transliterator.
* @param text the text to be transliterated
* @param index the position indices
* @param incremental if TRUE, then assume more characters may be inserted
@ -846,17 +1091,19 @@ public:
/**
* Returns a <code>Transliterator</code> object constructed from
* the given rule string. This will be a RuleBasedTransliterator,
* the given rule string. This will be a rule-based Transliterator,
* if the rule string contains only rules, or a
* CompoundTransliterator, if it contains ID blocks, or a
* NullTransliterator, if it contains ID blocks which parse as
* compound Transliterator, if it contains ID blocks, or a
* null Transliterator, if it contains ID blocks which parse as
* empty for the given direction.
*
* @param ID the id for the transliterator.
* @param rules rules, separated by ';'
* @param dir either FORWARD or REVERSE.
* @param parseError Struct to recieve information on position
* @param parseError Struct to receive information on position
* of error if an error is encountered
* @param status Output param set to success/failure code.
* @return a newly created Transliterator
* @stable ICU 2.0
*/
static Transliterator* U_EXPORT2 createFromRules(const UnicodeString& ID,
@ -1319,7 +1566,7 @@ inline int32_t Transliterator::getMaximumContextLength(void) const {
inline void Transliterator::setID(const UnicodeString& id) {
ID = id;
// NUL-terminate the ID string, which is a non-aliased copy.
ID.append((UChar)0);
ID.append((char16_t)0);
ID.truncate(ID.length()-1);
}

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -237,10 +237,10 @@ typedef enum UTimeZoneFormatParseOption {
*/
UTZFMT_PARSE_OPTION_ALL_STYLES = 0x01,
/**
* When parsing a time zone display name in UTZFMT_STYLE_SPECIFIC_SHORT,
* When parsing a time zone display name in \link UTZFMT_STYLE_SPECIFIC_SHORT \endlink,
* look for the IANA tz database compatible zone abbreviations in addition
* to the localized names coming from the {@link TimeZoneNames} currently
* used by the {@link TimeZoneFormat}.
* to the localized names coming from the icu::TimeZoneNames currently
* used by the icu::TimeZoneFormat.
* @stable ICU 54
*/
UTZFMT_PARSE_OPTION_TZ_DATABASE_ABBREVIATIONS = 0x02
@ -942,7 +942,7 @@ private:
* @param parsedLen the parsed length, or 0 on failure.
* @return the parsed offset in milliseconds.
*/
int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator,
int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, char16_t separator,
int32_t& parsedLen) const;
/**
@ -982,7 +982,7 @@ private:
* @param maxFields The maximum fields
* @return The offset string
*/
static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, UChar sep,
static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, char16_t sep,
OffsetFields minFields, OffsetFields maxFields, UnicodeString& result);
/**
@ -1012,7 +1012,7 @@ private:
* @param maxFields The maximum Fields to be parsed
* @return Parsed offset, 0 or positive number.
*/
static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep,
static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, char16_t sep,
OffsetFields minFields, OffsetFields maxFields);
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -291,14 +291,12 @@ public:
virtual UnicodeString& getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const;
/**
* @internal For specific users only until proposed publicly.
* @deprecated This API is ICU internal only.
* @internal ICU internal only, for specific users only until proposed publicly.
*/
virtual void loadAllDisplayNames(UErrorCode& status);
/**
* @internal For specific users only until proposed publicly.
* @deprecated This API is ICU internal only.
* @internal ICU internal only, for specific users only until proposed publicly.
*/
virtual void getDisplayNames(const UnicodeString& tzID, const UTimeZoneNameType types[], int32_t numTypes, UDate date, UnicodeString dest[], UErrorCode& status) const;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -139,6 +139,19 @@
* For example, subtracting 5 days from the date <code>September 12, 1996</code>
* results in <code>September 7, 1996</code>.
*
* <p>
* The Japanese calendar uses a combination of era name and year number.
* When an emperor of Japan abdicates and a new emperor ascends the throne,
* a new era is declared and year number is reset to 1. Even if the date of
* abdication is scheduled ahead of time, the new era name might not be
* announced until just before the date. In such case, ICU4C may include
* a start date of future era without actual era name, but not enabled
* by default. ICU4C users who want to test the behavior of the future era
* can enable the tentative era by:
* <ul>
* <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li>
* </ul>
*
* @stable ICU 2.0
*/
@ -425,8 +438,8 @@ enum UCalendarDateFields {
*/
UCAL_IS_LEAP_MONTH,
// Do not conditionalize with #ifndef U_HIDE_DEPRECATED_API,
// it is needed for layout of Calendar, DateFormat, and other objects
/* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
* it is needed for layout of Calendar, DateFormat, and other objects */
/**
* One more than the highest normal UCalendarDateFields value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -131,7 +131,7 @@ typedef enum {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UCOL_ATTRIBUTE_VALUE_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UColAttributeValue;
/**
@ -204,7 +204,7 @@ typedef enum {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UCOL_REORDER_CODE_LIMIT = 0x1005
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UColReorderCode;
/**
@ -342,8 +342,8 @@ typedef enum {
*/
UCOL_NUMERIC_COLLATION = UCOL_STRENGTH + 2,
// Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
// it is needed for layout of RuleBasedCollator object.
/* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
* it is needed for layout of RuleBasedCollator object. */
/**
* One more than the highest normal UColAttribute value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
@ -1067,7 +1067,7 @@ typedef enum {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UCOL_BOUND_VALUE_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UColBoundMode;
/**
@ -1149,7 +1149,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
* The recommended way to achieve "merged" sorting is by
* concatenating strings with U+FFFE between them.
* The concatenation has the same sort order as the merged sort keys,
* but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\uFFFE' + str2).
* but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\\uFFFE' + str2).
* Using strings with U+FFFE may yield shorter sort keys.
*
* For details about Sort Key Features see
@ -1294,6 +1294,7 @@ U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCod
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See ucol_setMaxVariable().
* @param coll collator to be set
* @param varTop primary weight, as returned by ucol_setVariableTop or ucol_getVariableTop
* @param status error code
* @see ucol_getVariableTop

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -152,7 +152,7 @@ ucol_reset(UCollationElements *elems);
* A single character may contain more than one collation element.
* @param elems The UCollationElements containing the text.
* @param status A pointer to a UErrorCode to receive any errors.
* @return The next collation elements ordering, otherwise returns NULLORDER
* @return The next collation elements ordering, otherwise returns UCOL_NULLORDER
* if an error has occured or if the end of string has been reached
* @stable ICU 2.0
*/
@ -168,7 +168,7 @@ ucol_next(UCollationElements *elems, UErrorCode *status);
* a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack
* buffer has been exhausted.
* @return The previous collation elements ordering, otherwise returns
* NULLORDER if an error has occured or if the start of string has
* UCOL_NULLORDER if an error has occured or if the start of string has
* been reached.
* @stable ICU 2.0
*/

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -6,7 +6,7 @@
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: ucsdet.h
* encoding: US-ASCII
* encoding: UTF-8
* indentation:4
*
* created on: 2005Aug04
@ -45,6 +45,10 @@
* in a single language, and a minimum of a few hundred bytes worth of plain text
* in the language are needed. The detection process will attempt to
* ignore html or xml style markup that could otherwise obscure the content.
* <p>
* An alternative to the ICU Charset Detector is the
* Compact Encoding Detector, https://github.com/google/compact_enc_det.
* It often gives more accurate results, especially with short input samples.
*/
@ -395,7 +399,7 @@ ucsdet_getDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status);
/**
* Enable or disable individual charset encoding.
* A name of charset encoding must be included in the names returned by
* {@link #getAllDetectableCharsets()}.
* {@link #ucsdet_getAllDetectableCharsets()}.
*
* @param ucsd a Charset detector.
* @param encoding encoding the name of charset encoding.

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -763,21 +763,19 @@ typedef enum UDateFormatField {
UDAT_RELATED_YEAR_FIELD = 34,
#endif /* U_HIDE_INTERNAL_API */
#ifndef U_HIDE_DRAFT_API
/**
* FieldPosition selector for 'b' field alignment.
* Displays midnight and noon for 12am and 12pm, respectively, if available;
* otherwise fall back to AM / PM.
* @draft ICU 57
* @stable ICU 57
*/
UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35,
/* FieldPosition selector for 'B' field alignment.
* Displays flexible day periods, such as "in the morning", if available.
* @draft ICU 57
* @stable ICU 57
*/
UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36,
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_INTERNAL_API
/**
@ -797,7 +795,7 @@ typedef enum UDateFormatField {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UDAT_FIELD_COUNT = 38
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UDateFormatField;
@ -819,7 +817,7 @@ typedef enum UDateFormatField {
* of error (e.g., the input field is UDAT_FIELD_COUNT).
* @stable ICU 4.4
*/
U_STABLE UCalendarDateFields U_EXPORT2
U_CAPI UCalendarDateFields U_EXPORT2
udat_toCalendarDateField(UDateFormatField field);
@ -851,7 +849,7 @@ udat_toCalendarDateField(UDateFormatField field);
* an error occurred.
* @stable ICU 2.0
*/
U_STABLE UDateFormat* U_EXPORT2
U_CAPI UDateFormat* U_EXPORT2
udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
@ -868,7 +866,7 @@ udat_open(UDateFormatStyle timeStyle,
* @param format The formatter to close.
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_close(UDateFormat* format);
@ -902,8 +900,8 @@ typedef enum UDateFormatBooleanAttribute {
*/
UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
// Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
// it is needed for layout of DateFormat object.
/* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
* it is needed for layout of DateFormat object. */
/**
* One more than the highest normal UDateFormatBooleanAttribute value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
@ -921,7 +919,7 @@ typedef enum UDateFormatBooleanAttribute {
* @return The value of attr.
* @stable ICU 53
*/
U_STABLE UBool U_EXPORT2
U_CAPI UBool U_EXPORT2
udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
/**
@ -934,7 +932,7 @@ udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute att
* @param status A pointer to an UErrorCode to receive any errors
* @stable ICU 53
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
@ -966,7 +964,7 @@ U_NAMESPACE_END
* @return A pointer to a UDateFormat identical to fmt.
* @stable ICU 2.0
*/
U_STABLE UDateFormat* U_EXPORT2
U_CAPI UDateFormat* U_EXPORT2
udat_clone(const UDateFormat *fmt,
UErrorCode *status);
@ -988,7 +986,7 @@ udat_clone(const UDateFormat *fmt,
* @see UFieldPosition
* @stable ICU 2.0
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_format( const UDateFormat* format,
UDate dateToFormat,
UChar* result,
@ -1018,7 +1016,7 @@ udat_format( const UDateFormat* format,
* @see UFieldPosition
* @stable ICU 55
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_formatCalendar( const UDateFormat* format,
UCalendar* calendar,
UChar* result,
@ -1053,7 +1051,7 @@ udat_formatCalendar( const UDateFormat* format,
* @see UFieldPositionIterator
* @stable ICU 55
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_formatForFields( const UDateFormat* format,
UDate dateToFormat,
UChar* result,
@ -1091,7 +1089,7 @@ udat_formatForFields( const UDateFormat* format,
* @see UFieldPositionIterator
* @stable ICU 55
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_formatCalendarForFields( const UDateFormat* format,
UCalendar* calendar,
UChar* result,
@ -1125,7 +1123,7 @@ udat_formatCalendarForFields( const UDateFormat* format,
* @see udat_format
* @stable ICU 2.0
*/
U_STABLE UDate U_EXPORT2
U_CAPI UDate U_EXPORT2
udat_parse(const UDateFormat* format,
const UChar* text,
int32_t textLength,
@ -1153,7 +1151,7 @@ udat_parse(const UDateFormat* format,
* @see udat_format
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_parseCalendar(const UDateFormat* format,
UCalendar* calendar,
const UChar* text,
@ -1170,7 +1168,7 @@ udat_parseCalendar(const UDateFormat* format,
* @see udat_setLenient
* @stable ICU 2.0
*/
U_STABLE UBool U_EXPORT2
U_CAPI UBool U_EXPORT2
udat_isLenient(const UDateFormat* fmt);
/**
@ -1182,7 +1180,7 @@ udat_isLenient(const UDateFormat* fmt);
* @see dat_isLenient
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setLenient( UDateFormat* fmt,
UBool isLenient);
@ -1195,7 +1193,7 @@ udat_setLenient( UDateFormat* fmt,
* @see udat_setCalendar
* @stable ICU 2.0
*/
U_STABLE const UCalendar* U_EXPORT2
U_CAPI const UCalendar* U_EXPORT2
udat_getCalendar(const UDateFormat* fmt);
/**
@ -1207,7 +1205,7 @@ udat_getCalendar(const UDateFormat* fmt);
* @see udat_setCalendar
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setCalendar( UDateFormat* fmt,
const UCalendar* calendarToSet);
@ -1220,7 +1218,7 @@ udat_setCalendar( UDateFormat* fmt,
* @see udat_setNumberFormat
* @stable ICU 2.0
*/
U_STABLE const UNumberFormat* U_EXPORT2
U_CAPI const UNumberFormat* U_EXPORT2
udat_getNumberFormat(const UDateFormat* fmt);
/**
@ -1232,7 +1230,7 @@ udat_getNumberFormat(const UDateFormat* fmt);
* @see udat_setNumberFormatForField
* @stable ICU 54
*/
U_STABLE const UNumberFormat* U_EXPORT2
U_CAPI const UNumberFormat* U_EXPORT2
udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
/**
@ -1250,7 +1248,7 @@ udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
* @see udat_getNumberFormatForField
* @stable ICU 54
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_adoptNumberFormatForFields( UDateFormat* fmt,
const UChar* fields,
UNumberFormat* numberFormatToSet,
@ -1267,7 +1265,7 @@ udat_adoptNumberFormatForFields( UDateFormat* fmt,
* @see udat_setNumberFormatForField
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setNumberFormat( UDateFormat* fmt,
const UNumberFormat* numberFormatToSet);
/**
@ -1279,7 +1277,7 @@ udat_setNumberFormat( UDateFormat* fmt,
* @see udat_getNumberFormat
* @stable ICU 54
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_adoptNumberFormat( UDateFormat* fmt,
UNumberFormat* numberFormatToAdopt);
/**
@ -1291,7 +1289,7 @@ udat_adoptNumberFormat( UDateFormat* fmt,
* @see udat_countAvailable
* @stable ICU 2.0
*/
U_STABLE const char* U_EXPORT2
U_CAPI const char* U_EXPORT2
udat_getAvailable(int32_t localeIndex);
/**
@ -1302,7 +1300,7 @@ udat_getAvailable(int32_t localeIndex);
* @see udat_getAvailable
* @stable ICU 2.0
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_countAvailable(void);
/**
@ -1315,7 +1313,7 @@ udat_countAvailable(void);
* @see udat_Set2DigitYearStart
* @stable ICU 2.0
*/
U_STABLE UDate U_EXPORT2
U_CAPI UDate U_EXPORT2
udat_get2DigitYearStart( const UDateFormat *fmt,
UErrorCode *status);
@ -1329,7 +1327,7 @@ udat_get2DigitYearStart( const UDateFormat *fmt,
* @see udat_Set2DigitYearStart
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_set2DigitYearStart( UDateFormat *fmt,
UDate d,
UErrorCode *status);
@ -1346,7 +1344,7 @@ udat_set2DigitYearStart( UDateFormat *fmt,
* @see udat_applyPattern
* @stable ICU 2.0
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_toPattern( const UDateFormat *fmt,
UBool localized,
UChar *result,
@ -1363,7 +1361,7 @@ udat_toPattern( const UDateFormat *fmt,
* @see udat_toPattern
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_applyPattern( UDateFormat *format,
UBool localized,
const UChar *pattern,
@ -1489,7 +1487,7 @@ typedef struct UDateFormatSymbols UDateFormatSymbols;
* @see udat_setSymbols
* @stable ICU 2.0
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_getSymbols(const UDateFormat *fmt,
UDateFormatSymbolType type,
int32_t symbolIndex,
@ -1509,7 +1507,7 @@ udat_getSymbols(const UDateFormat *fmt,
* @see udat_setSymbols
* @stable ICU 2.0
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
udat_countSymbols( const UDateFormat *fmt,
UDateFormatSymbolType type);
@ -1528,7 +1526,7 @@ udat_countSymbols( const UDateFormat *fmt,
* @see udat_countSymbols
* @stable ICU 2.0
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setSymbols( UDateFormat *format,
UDateFormatSymbolType type,
int32_t symbolIndex,
@ -1545,7 +1543,7 @@ udat_setSymbols( UDateFormat *format,
* @return the locale name
* @stable ICU 2.8
*/
U_STABLE const char* U_EXPORT2
U_CAPI const char* U_EXPORT2
udat_getLocaleByType(const UDateFormat *fmt,
ULocDataLocaleType type,
UErrorCode* status);
@ -1558,7 +1556,7 @@ udat_getLocaleByType(const UDateFormat *fmt,
* @param status A pointer to an UErrorCode to receive any errors
* @stable ICU 51
*/
U_DRAFT void U_EXPORT2
U_CAPI void U_EXPORT2
udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
/**
@ -1570,7 +1568,7 @@ udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
* @return The UDisplayContextValue for the specified type.
* @stable ICU 53
*/
U_STABLE UDisplayContext U_EXPORT2
U_CAPI UDisplayContext U_EXPORT2
udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
#ifndef U_HIDE_INTERNAL_API

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -8,7 +8,7 @@
*
*******************************************************************************
* file name: udatpg.h
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@ -86,8 +86,8 @@ typedef enum UDateTimePatternField {
/** @stable ICU 3.8 */
UDATPG_ZONE_FIELD,
// Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
// it is needed for layout of DateTimePatternGenerator object.
/* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
* it is needed for layout of DateTimePatternGenerator object. */
/**
* One more than the highest normal UDateTimePatternField value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
@ -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

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
@ -57,7 +57,7 @@ typedef enum UFormattableType {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UFMT_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UFormattableType;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
@ -49,11 +49,11 @@ enum UGender {
*/
typedef enum UGender UGender;
struct UGenderInfo;
/**
* Opaque UGenderInfo object for use in C programs.
* @stable ICU 50
*/
struct UGenderInfo;
typedef struct UGenderInfo UGenderInfo;
/**
@ -77,7 +77,7 @@ ugender_getInstance(const char *locale, UErrorCode *status);
* @stable ICU 50
*/
U_STABLE UGender U_EXPORT2
ugender_getListGender(const UGenderInfo* genderinfo, const UGender *genders, int32_t size, UErrorCode *status);
ugender_getListGender(const UGenderInfo* genderInfo, const UGender *genders, int32_t size, UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -0,0 +1,150 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
* Copyright (C) 2015-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*****************************************************************************************
*/
#ifndef ULISTFORMATTER_H
#define ULISTFORMATTER_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/localpointer.h"
/**
* \file
* \brief C API: Format a list in a locale-appropriate way.
*
* A UListFormatter is used to format a list of items in a locale-appropriate way,
* using data from CLDR.
* Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted
* as "Alice, Bob, Charlie, and Delta" in English.
*/
/**
* Opaque UListFormatter object for use in C
* @stable ICU 55
*/
struct UListFormatter;
typedef struct UListFormatter UListFormatter; /**< C typedef for struct UListFormatter. @stable ICU 55 */
#ifndef U_HIDE_DRAFT_API
/**
* FieldPosition and UFieldPosition selectors for format fields
* defined by ListFormatter.
* @draft ICU 63
*/
typedef enum UListFormatterField {
/**
* The literal text in the result which came from the resources.
* @draft ICU 63
*/
ULISTFMT_LITERAL_FIELD,
/**
* The element text in the result which came from the input strings.
* @draft ICU 63
*/
ULISTFMT_ELEMENT_FIELD
} UListFormatterField;
#endif // U_HIDE_DRAFT_API
/**
* Open a new UListFormatter object using the rules for a given locale.
* @param locale
* The locale whose rules should be used; may be NULL for
* default locale.
* @param status
* A pointer to a standard ICU UErrorCode (input/output parameter).
* Its input value must pass the U_SUCCESS() test, or else the
* function returns immediately. The caller should check its output
* value with U_FAILURE(), or use with function chaining (see User
* Guide for details).
* @return
* A pointer to a UListFormatter object for the specified locale,
* or NULL if an error occurred.
* @stable ICU 55
*/
U_CAPI UListFormatter* U_EXPORT2
ulistfmt_open(const char* locale,
UErrorCode* status);
/**
* Close a UListFormatter object. Once closed it may no longer be used.
* @param listfmt
* The UListFormatter object to close.
* @stable ICU 55
*/
U_CAPI void U_EXPORT2
ulistfmt_close(UListFormatter *listfmt);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* \class LocalUListFormatterPointer
* "Smart pointer" class, closes a UListFormatter via ulistfmt_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @stable ICU 55
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer, UListFormatter, ulistfmt_close);
U_NAMESPACE_END
#endif
/**
* Formats a list of strings using the conventions established for the
* UListFormatter object.
* @param listfmt
* The UListFormatter object specifying the list conventions.
* @param strings
* An array of pointers to UChar strings; the array length is
* specified by stringCount. Must be non-NULL if stringCount > 0.
* @param stringLengths
* An array of string lengths corresponding to the strings[]
* parameter; any individual length value may be negative to indicate
* that the corresponding strings[] entry is 0-terminated, or
* stringLengths itself may be NULL if all of the strings are
* 0-terminated. If non-NULL, the stringLengths array must have
* stringCount entries.
* @param stringCount
* the number of entries in strings[], and the number of entries
* in the stringLengths array if it is not NULL. Must be >= 0.
* @param result
* A pointer to a buffer to receive the formatted list.
* @param resultCapacity
* The maximum size of result.
* @param status
* A pointer to a standard ICU UErrorCode (input/output parameter).
* Its input value must pass the U_SUCCESS() test, or else the
* function returns immediately. The caller should check its output
* value with U_FAILURE(), or use with function chaining (see User
* Guide for details).
* @return
* The total buffer size needed; if greater than resultLength, the
* output was truncated. May be <=0 if unable to determine the
* total buffer size needed (e.g. for illegal arguments).
* @stable ICU 55
*/
U_CAPI int32_t U_EXPORT2
ulistfmt_format(const UListFormatter* listfmt,
const UChar* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
UChar* result,
int32_t resultCapacity,
UErrorCode* status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
@ -8,7 +8,7 @@
* *
******************************************************************************
* file name: ulocdata.h
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@ -55,7 +55,7 @@ typedef enum ULocaleDataExemplarSetType {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
ULOCDATA_ES_COUNT=4
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} ULocaleDataExemplarSetType;
/** The possible types of delimiters.
@ -76,7 +76,7 @@ typedef enum ULocaleDataDelimiterType {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
ULOCDATA_DELIMITER_COUNT = 4
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} ULocaleDataDelimiterType;
/**
@ -207,7 +207,7 @@ typedef enum UMeasurementSystem {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UMS_LIMIT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UMeasurementSystem;
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
@ -8,7 +8,7 @@
********************************************************************
*
* file name: umsg.h
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -29,9 +29,13 @@
/**
* \file
* \brief C API: NumberFormat
* \brief C API: Compatibility APIs for number formatting.
*
* <h2> Number Format C API </h2>
*
* <p><strong>IMPORTANT:</strong> New users with are strongly encouraged to
* see if unumberformatter.h fits their use case. Although not deprecated,
* this header is provided for backwards compatibility only.
*
* Number Format C API Provides functions for
* formatting and parsing a number. Also provides methods for
@ -115,7 +119,7 @@
* <P>
* You can also control the display of numbers with such function as
* unum_getAttributes() and unum_setAttributes(), which let you set the
* miminum fraction digits, grouping, etc.
* minimum fraction digits, grouping, etc.
* @see UNumberFormatAttributes for more details
* <P>
* You can also use forms of the parse and format methods with
@ -126,7 +130,7 @@
* </ul>
* <p>
* It is also possible to change or set the symbols used for a particular
* locale like the currency symbol, the grouping seperator , monetary seperator
* locale like the currency symbol, the grouping separator , monetary separator
* etc by making use of functions unum_setSymbols() and unum_getSymbols().
*/
@ -250,7 +254,7 @@ typedef enum UNumberFormatStyle {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UNUM_FORMAT_STYLE_COUNT=17,
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
/**
* Default format
@ -264,8 +268,13 @@ typedef enum UNumberFormatStyle {
UNUM_IGNORE = UNUM_PATTERN_DECIMAL
} UNumberFormatStyle;
/** The possible number format rounding modes.
* @stable ICU 2.0
/** The possible number format rounding modes.
*
* <p>
* For more detail on rounding modes, see:
* http://userguide.icu-project.org/formatparse/numbers/rounding-modes
*
* @stable ICU 2.0
*/
typedef enum UNumberFormatRoundingMode {
UNUM_ROUND_CEILING,
@ -327,8 +336,8 @@ enum UCurrencySpacing {
/** @stable ICU 4.8 */
UNUM_CURRENCY_INSERT,
// Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
// it is needed for layout of DecimalFormatSymbols object.
/* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
* it is needed for layout of DecimalFormatSymbols object. */
/**
* One more than the highest normal UCurrencySpacing value.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
@ -372,7 +381,7 @@ typedef enum UNumberFormatFields {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UNUM_FIELD_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UNumberFormatFields;
@ -391,6 +400,10 @@ typedef enum UNumberFormatFields {
* number format is opened using the given pattern, which must conform
* to the syntax described in DecimalFormat or RuleBasedNumberFormat,
* respectively.
*
* <p><strong>NOTE::</strong> New users with are strongly encouraged to
* use unumf_openWithSkeletonAndLocale instead of unum_open.
*
* @param pattern A pattern specifying the format to use.
* This parameter is ignored unless the style is
* UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.
@ -554,6 +567,57 @@ unum_formatDouble( const UNumberFormat* fmt,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status);
/**
* Format a double using a UNumberFormat according to the UNumberFormat's locale,
* and initialize a UFieldPositionIterator that enumerates the subcomponents of
* the resulting string.
*
* @param format
* The formatter to use.
* @param number
* The number to format.
* @param result
* A pointer to a buffer to receive the NULL-terminated formatted
* number. If the formatted number fits into dest but cannot be
* NULL-terminated (length == resultLength) then the error code is set
* to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't
* fit into result then the error code is set to
* U_BUFFER_OVERFLOW_ERROR.
* @param resultLength
* The maximum size of result.
* @param fpositer
* A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
* (may be NULL if field position information is not needed, but in this
* case it's preferable to use {@link #unum_formatDouble}). Iteration
* information already present in the UFieldPositionIterator is deleted,
* and the iterator is reset to apply to the fields in the formatted
* string created by this function call. The field values and indexes
* returned by {@link #ufieldpositer_next} represent fields denoted by
* the UNumberFormatFields enum. Fields are not returned in a guaranteed
* order. Fields cannot overlap, but they may nest. For example, 1234
* could format as "1,234" which might consist of a grouping separator
* field for ',' and an integer field encompassing the entire string.
* @param status
* A pointer to an UErrorCode to receive any errors
* @return
* The total buffer size needed; if greater than resultLength, the
* output was truncated.
* @see unum_formatDouble
* @see unum_parse
* @see unum_parseDouble
* @see UFieldPositionIterator
* @see UNumberFormatFields
* @stable ICU 59
*/
U_STABLE int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
UChar* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status);
/**
* Format a decimal number using a UNumberFormat.
* The number will be formatted according to the UNumberFormat's locale.
@ -652,56 +716,6 @@ unum_formatUFormattable(const UNumberFormat* fmt,
UFieldPosition *pos,
UErrorCode *status);
/**
* Format a double using a UNumberFormat according to the UNumberFormat's locale,
* and initialize a UFieldPositionIterator that enumerates the subcomponents of
* the resulting string.
*
* @param format
* The formatter to use.
* @param number
* The number to format.
* @param result
* A pointer to a buffer to receive the NULL-terminated formatted
* number. If the formatted number fits into dest but cannot be
* NULL-terminated (length == resultLength) then the error code is set
* to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't
* fit into result then the error code is set to
* U_BUFFER_OVERFLOW_ERROR.
* @param resultLength
* The maximum size of result.
* @param fpositer
* A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
* (may be NULL if field position information is not needed, but in this
* case it's preferable to use {@link #unum_formatDouble}). Iteration
* information already present in the UFieldPositionIterator is deleted,
* and the iterator is reset to apply to the fields in the formatted
* string created by this function call. The field values and indexes
* returned by {@link #ufieldpositer_next} represent fields denoted by
* the UNumberFormatFields enum. Fields are not returned in a guaranteed
* order. Fields cannot overlap, but they may nest. For example, 1234
* could format as "1,234" which might consist of a grouping separator
* field for ',' and an integer field encompassing the entire string.
* @param status
* A pointer to an UErrorCode to receive any errors
* @return
* The total buffer size needed; if greater than resultLength, the
* output was truncated.
* @see unum_formatDouble
* @see unum_parse
* @see unum_parseDouble
* @see UFieldPositionIterator
* @see UNumberFormatFields
* @stable ICU 59
*/
U_STABLE int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
UChar* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status);
/**
* Parse a string into an integer using a UNumberFormat.
* The string will be parsed according to the UNumberFormat's locale.
@ -880,7 +894,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt,
* @param localized TRUE if the pattern is localized, FALSE otherwise.
* @param pattern The new pattern
* @param patternLength The length of pattern, or -1 if null-terminated.
* @param parseError A pointer to UParseError to recieve information
* @param parseError A pointer to UParseError to receive information
* about errors occurred during parsing, or NULL if no parse error
* information is desired.
* @param status A pointer to an input-output UErrorCode.
@ -1004,6 +1018,8 @@ typedef enum UNumberFormatAttribute {
* <p>Example: setting the scale to 3, 123 formats as "123,000"
* <p>Example: setting the scale to -4, 123 formats as "0.0123"
*
* This setting is analogous to getMultiplierScale() and setMultiplierScale() in decimfmt.h.
*
* @stable ICU 51 */
UNUM_SCALE = 21,
#ifndef U_HIDE_INTERNAL_API
@ -1043,7 +1059,7 @@ typedef enum UNumberFormatAttribute {
* Default: 0 (unset)
* @stable ICU 50
*/
UNUM_PARSE_NO_EXPONENT,
UNUM_PARSE_NO_EXPONENT = 0x1001,
/**
* if this attribute is set to 1, specifies that, if the pattern contains a
@ -1058,7 +1074,21 @@ typedef enum UNumberFormatAttribute {
/* The following cannot be #ifndef U_HIDE_INTERNAL_API, needed in .h file variable declararions */
/** Limit of boolean attributes.
* @internal */
UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1003
UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1003,
/**
* Whether parsing is sensitive to case (lowercase/uppercase).
* TODO: Add to the test suite.
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UNUM_PARSE_CASE_SENSITIVE = 0x1004,
/**
* Formatting: whether to show the plus sign on non-negative numbers.
* TODO: Add to the test suite.
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UNUM_SIGN_ALWAYS_SHOWN = 0x1005,
} UNumberFormatAttribute;
/**
@ -1342,7 +1372,7 @@ typedef enum UNumberFormatSymbol {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UNUM_FORMAT_SYMBOL_COUNT = 28
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UNumberFormatSymbol;
/**

View file

@ -0,0 +1,729 @@
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#ifndef __UNUMBERFORMATTER_H__
#define __UNUMBERFORMATTER_H__
#include "unicode/ufieldpositer.h"
#include "unicode/umisc.h"
/**
* \file
* \brief C-compatible API for localized number formatting; not recommended for C++.
*
* This is the C-compatible version of the NumberFormatter API introduced in ICU 60. C++ users should
* include unicode/numberformatter.h and use the proper C++ APIs.
*
* The C API accepts a number skeleton string for specifying the settings for formatting, which covers a
* very large subset of all possible number formatting features. For more information on number skeleton
* strings, see unicode/numberformatter.h.
*
* When using UNumberFormatter, which is treated as immutable, the results are exported to a mutable
* UFormattedNumber object, which you subsequently use for populating your string buffer or iterating over
* the fields.
*
* Example code:
* <pre>
* // Setup:
* UErrorCode ec = U_ZERO_ERROR;
* UNumberFormatter* uformatter = unumf_openForSkeletonAndLocale(u"precision-integer", -1, "en", &ec);
* UFormattedNumber* uresult = unumf_openResult(&ec);
* if (U_FAILURE(ec)) { return; }
*
* // Format a double:
* unumf_formatDouble(uformatter, 5142.3, uresult, &ec);
* if (U_FAILURE(ec)) { return; }
*
* // Export the string to a malloc'd buffer:
* int32_t len = unumf_resultToString(uresult, NULL, 0, &ec);
* // at this point, ec == U_BUFFER_OVERFLOW_ERROR
* ec = U_ZERO_ERROR;
* UChar* buffer = (UChar*) malloc((len+1)*sizeof(UChar));
* unumf_resultToString(uresult, buffer, len+1, &ec);
* if (U_FAILURE(ec)) { return; }
* // buffer should equal "5,142"
*
* // Cleanup:
* unumf_close(uformatter);
* unumf_closeResult(uresult);
* free(buffer);
* </pre>
*
* If you are a C++ user linking against the C libraries, you can use the LocalPointer versions of these
* APIs. The following example uses LocalPointer with the decimal number and field position APIs:
*
* <pre>
* // Setup:
* LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(u"percent", -1, "en", &ec));
* LocalUFormattedNumberPointer uresult(unumf_openResult(&ec));
* if (U_FAILURE(ec)) { return; }
*
* // Format a decimal number:
* unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec);
* if (U_FAILURE(ec)) { return; }
*
* // Get the location of the percent sign:
* UFieldPosition ufpos = {UNUM_PERCENT_FIELD, 0, 0};
* unumf_resultNextFieldPosition(uresult.getAlias(), &ufpos, &ec);
* // ufpos should contain beginIndex=7 and endIndex=8 since the string is "0.00987%"
*
* // No need to do any cleanup since we are using LocalPointer.
* </pre>
*/
#ifndef U_HIDE_DRAFT_API
/**
* An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123
* meters in <em>en-CA</em>:
*
* <p>
* <ul>
* <li>NARROW*: "$123.00" and "123 m"
* <li>SHORT: "US$ 123.00" and "123 m"
* <li>FULL_NAME: "123.00 US dollars" and "123 meters"
* <li>ISO_CODE: "USD 123.00" and undefined behavior
* <li>HIDDEN: "123.00" and "123"
* </ul>
*
* <p>
* This enum is similar to {@link UMeasureFormatWidth}.
*
* @draft ICU 60
*/
typedef enum UNumberUnitWidth {
/**
* Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available
* abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more
* information on the difference between NARROW and SHORT, see SHORT.
*
* <p>
* In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for
* currencies.
*
* @draft ICU 60
*/
UNUM_UNIT_WIDTH_NARROW,
/**
* Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or
* symbol when there may be ambiguity. This is the default behavior.
*
* <p>
* For example, in <em>es-US</em>, the SHORT form for Fahrenheit is "{0} °F", but the NARROW form is "{0}°",
* since Fahrenheit is the customary unit for temperature in that locale.
*
* <p>
* In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for
* currencies.
*
* @draft ICU 60
*/
UNUM_UNIT_WIDTH_SHORT,
/**
* Print the full name of the unit, without any abbreviations.
*
* <p>
* In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for
* currencies.
*
* @draft ICU 60
*/
UNUM_UNIT_WIDTH_FULL_NAME,
/**
* Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this
* option is currently undefined for use with measure units.
*
* <p>
* In CLDR, this option corresponds to the "¤¤" placeholder for currencies.
*
* @draft ICU 60
*/
UNUM_UNIT_WIDTH_ISO_CODE,
/**
* Format the number according to the specified unit, but do not display the unit. For currencies, apply
* monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is
* equivalent to not specifying the unit at all.
*
* @draft ICU 60
*/
UNUM_UNIT_WIDTH_HIDDEN,
/**
* 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
} UNumberUnitWidth;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* 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 63
*/
typedef enum UNumberGroupingStrategy {
/**
* 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
#ifndef U_HIDE_INTERNAL_API
,
/**
* One more than the highest UNumberGroupingStrategy value.
*
* @internal ICU 62: The numeric value may change over time; see ICU ticket #12420.
*/
UNUM_GROUPING_COUNT
#endif /* U_HIDE_INTERNAL_API */
} UNumberGroupingStrategy;
#ifndef U_HIDE_DEPRECATED_API
/**
* Old name for compatibility: will be removed in ICU 64.
* @deprecated ICU 63
*/
typedef UNumberGroupingStrategy UGroupingStrategy;
#endif /* U_HIDE_DEPRECATED_API */
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* 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", "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>
* The exact format, including the position and the code point of the sign, differ by locale.
*
* @draft ICU 60
*/
typedef enum UNumberSignDisplay {
/**
* Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default
* behavior.
*
* @draft ICU 60
*/
UNUM_SIGN_AUTO,
/**
* 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,
/**
* Do not show the sign on positive or negative numbers.
*
* @draft ICU 60
*/
UNUM_SIGN_NEVER,
/**
* Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers.
*
* <p>
* The accounting format is defined in CLDR and varies by locale; in many Western locales, the format is a pair
* of parentheses around the number.
*
* <p>
* Note: Since CLDR defines the accounting format in the monetary context only, this option falls back to the
* AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the
* future.
*
* @draft ICU 60
*/
UNUM_SIGN_ACCOUNTING,
/**
* 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,
/**
* 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,
/**
* One more than the highest UNumberSignDisplay value.
*
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
*/
UNUM_SIGN_COUNT
} UNumberSignDisplay;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* An enum declaring how to render the decimal separator.
*
* <p>
* <ul>
* <li>UNUM_DECIMAL_SEPARATOR_AUTO: "1", "1.1"
* <li>UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1"
* </ul>
*/
typedef enum UNumberDecimalSeparatorDisplay {
/**
* Show the decimal separator when there are one or more digits to display after the separator, and do not show
* it otherwise. This is the default behavior.
*
* @draft ICU 60
*/
UNUM_DECIMAL_SEPARATOR_AUTO,
/**
* Always show the decimal separator, even if there are no digits to display after the separator.
*
* @draft ICU 60
*/
UNUM_DECIMAL_SEPARATOR_ALWAYS,
/**
* 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
} UNumberDecimalSeparatorDisplay;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
struct UNumberFormatter;
/**
* C-compatible version of icu::number::LocalizedNumberFormatter.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @draft ICU 62
*/
typedef struct UNumberFormatter UNumberFormatter;
struct UFormattedNumber;
/**
* C-compatible version of icu::number::FormattedNumber.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @draft ICU 62
*/
typedef struct UFormattedNumber UFormattedNumber;
/**
* Creates a new UNumberFormatter for the given skeleton string and locale. This is currently the only
* method for creating a new UNumberFormatter.
*
* Objects of type UNumberFormatter returned by this method are threadsafe.
*
* For more details on skeleton strings, see the documentation in numberformatter.h. For more details on
* the usage of this API, see the documentation at the top of unumberformatter.h.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param skeleton The skeleton string, like u"percent precision-integer"
* @param skeletonLen The number of UChars in the skeleton string, or -1 it it is NUL-terminated.
* @param locale The NUL-terminated locale ID.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT UNumberFormatter* U_EXPORT2
unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
UErrorCode* ec);
/**
* Creates a new UFormattedNumber for holding the result of a number formatting operation.
*
* Objects of type UFormattedNumber are not guaranteed to be threadsafe.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT UFormattedNumber* U_EXPORT2
unumf_openResult(UErrorCode* ec);
/**
* Uses a UNumberFormatter to format an integer to a UFormattedNumber. A string, field position, and other
* information can be retrieved from the UFormattedNumber.
*
* The UNumberFormatter can be shared between threads. Each thread should have its own local
* UFormattedNumber, however, for storing the result of the formatting operation.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
* @param value The number to be formatted.
* @param uresult The object that will be mutated to store the result; see unumf_openResult.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
UErrorCode* ec);
/**
* Uses a UNumberFormatter to format a double to a UFormattedNumber. A string, field position, and other
* information can be retrieved from the UFormattedNumber.
*
* The UNumberFormatter can be shared between threads. Each thread should have its own local
* UFormattedNumber, however, for storing the result of the formatting operation.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
* @param value The number to be formatted.
* @param uresult The object that will be mutated to store the result; see unumf_openResult.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
UErrorCode* ec);
/**
* Uses a UNumberFormatter to format a decimal number to a UFormattedNumber. A string, field position, and
* other information can be retrieved from the UFormattedNumber.
*
* The UNumberFormatter can be shared between threads. Each thread should have its own local
* UFormattedNumber, however, for storing the result of the formatting operation.
*
* The syntax of the unformatted number is a "numeric string" as defined in the Decimal Arithmetic
* Specification, available at http://speleotrove.com/decimal
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
* @param value The numeric string to be formatted.
* @param valueLen The length of the numeric string, or -1 if it is NUL-terminated.
* @param uresult The object that will be mutated to store the result; see unumf_openResult.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
UFormattedNumber* uresult, UErrorCode* ec);
/**
* Extracts the result number string out of a UFormattedNumber to a UChar buffer if possible.
* If bufferCapacity is greater than the required length, a terminating NUL is written.
* If bufferCapacity is less than the required length, an error code is set.
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uresult The object containing the formatted number.
* @param buffer Where to save the string output.
* @param bufferCapacity The number of UChars available in the buffer.
* @param ec Set if an error occurs.
* @return The required length.
* @draft ICU 62
*/
U_DRAFT int32_t U_EXPORT2
unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
UErrorCode* ec);
/**
* Determines the start and end indices of the next occurrence of the given <em>field</em> in the
* output string. This allows you to determine the locations of, for example, the integer part,
* fraction part, or symbols.
*
* If a field occurs just once, calling this method will find that occurrence and return it. If a
* field occurs multiple times, this method may be called repeatedly with the following pattern:
*
* <pre>
* UFieldPosition ufpos = {UNUM_GROUPING_SEPARATOR_FIELD, 0, 0};
* while (unumf_resultNextFieldPosition(uresult, ufpos, &ec)) {
* // do something with ufpos.
* }
* </pre>
*
* This method is useful if you know which field to query. If you want all available field position
* information, use unumf_resultGetAllFieldPositions().
*
* NOTE: All fields of the UFieldPosition must be initialized before calling this method.
*
* @param uresult The object containing the formatted number.
* @param ufpos
* Input+output variable. On input, the "field" property determines which field to look up,
* and the "endIndex" property determines where to begin the search. On output, the
* "beginIndex" field is set to the beginning of the first occurrence of the field after the
* input "endIndex", and "endIndex" is set to the end of that occurrence of the field
* (exclusive index). If a field position is not found, the FieldPosition is not changed and
* the method returns FALSE.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT UBool U_EXPORT2
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec);
/**
* Populates the given iterator with all fields in the formatted output string. This allows you to
* determine the locations of the integer part, fraction part, and sign.
*
* If you need information on only one field, use unumf_resultNextFieldPosition().
*
* @param uresult The object containing the formatted number.
* @param ufpositer
* A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}. Iteration
* information already present in the UFieldPositionIterator is deleted, and the iterator is reset
* to apply to the fields in the formatted string created by this function call. The field values
* and indexes returned by {@link #ufieldpositer_next} represent fields denoted by
* the UNumberFormatFields enum. Fields are not returned in a guaranteed order. Fields cannot
* overlap, but they may nest. For example, 1234 could format as "1,234" which might consist of a
* grouping separator field for ',' and an integer field encompassing the entire string.
* @param ec Set if an error occurs.
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
UErrorCode* ec);
/**
* Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uformatter An object created by unumf_openForSkeletonAndLocale().
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_close(UNumberFormatter* uformatter);
/**
* Releases the UFormattedNumber created by unumf_openResult().
*
* NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
*
* @param uresult An object created by unumf_openResult().
* @draft ICU 62
*/
U_DRAFT void U_EXPORT2
unumf_closeResult(UFormattedNumber* uresult);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* \class LocalUNumberFormatterPointer
* "Smart pointer" class; closes a UNumberFormatter via unumf_close().
* For most methods see the LocalPointerBase base class.
*
* Usage:
* <pre>
* LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(...));
* // no need to explicitly call unumf_close()
* </pre>
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 62
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatterPointer, UNumberFormatter, unumf_close);
/**
* \class LocalUNumberFormatterPointer
* "Smart pointer" class; closes a UFormattedNumber via unumf_closeResult().
* For most methods see the LocalPointerBase base class.
*
* Usage:
* <pre>
* LocalUFormattedNumberPointer uformatter(unumf_openResult(...));
* // no need to explicitly call unumf_closeResult()
* </pre>
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 62
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberPointer, UFormattedNumber, unumf_closeResult);
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
#endif /* U_HIDE_DRAFT_API */
#endif //__UNUMBERFORMATTER_H__
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
@ -15,6 +15,10 @@
#if !UCONFIG_NO_FORMATTING
#include "unicode/localpointer.h"
#include "unicode/uenum.h"
#ifndef U_HIDE_INTERNAL_API
#include "unicode/unum.h"
#endif /* U_HIDE_INTERNAL_API */
/**
* \file
@ -60,7 +64,7 @@ enum UPluralType {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UPLURAL_TYPE_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
};
/**
* @stable ICU 50
@ -83,7 +87,7 @@ typedef struct UPluralRules UPluralRules; /**< C typedef for struct UPluralRule
* @return A UPluralRules for the specified locale, or NULL if an error occurred.
* @stable ICU 4.8
*/
U_STABLE UPluralRules* U_EXPORT2
U_CAPI UPluralRules* U_EXPORT2
uplrules_open(const char *locale, UErrorCode *status);
/**
@ -95,7 +99,7 @@ uplrules_open(const char *locale, UErrorCode *status);
* @return A UPluralRules for the specified locale, or NULL if an error occurred.
* @stable ICU 50
*/
U_DRAFT UPluralRules* U_EXPORT2
U_CAPI UPluralRules* U_EXPORT2
uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);
/**
@ -103,7 +107,7 @@ uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);
* @param uplrules The UPluralRules object to close.
* @stable ICU 4.8
*/
U_STABLE void U_EXPORT2
U_CAPI void U_EXPORT2
uplrules_close(UPluralRules *uplrules);
@ -138,12 +142,53 @@ U_NAMESPACE_END
* @return The length of keyword.
* @stable ICU 4.8
*/
U_STABLE int32_t U_EXPORT2
U_CAPI int32_t U_EXPORT2
uplrules_select(const UPluralRules *uplrules,
double number,
UChar *keyword, int32_t capacity,
UErrorCode *status);
#ifndef U_HIDE_INTERNAL_API
/**
* Given a number, returns the keyword of the first rule that applies to the
* number, according to the UPluralRules object and given the number format
* specified by the UNumberFormat object.
* Note: This internal preview interface may be removed in the future if
* an architecturally cleaner solution reaches stable status.
* @param uplrules The UPluralRules object specifying the rules.
* @param number The number for which the rule has to be determined.
* @param fmt The UNumberFormat specifying how the number will be formatted
* (this can affect the plural form, e.g. "1 dollar" vs "1.0 dollars").
* If this is NULL, the function behaves like uplrules_select.
* @param keyword The keyword of the rule that applies to number.
* @param capacity The capacity of the keyword buffer.
* @param status A pointer to a UErrorCode to receive any errors.
* @return The length of keyword.
* @internal ICU 59 technology preview, may be removed in the future
*/
U_INTERNAL int32_t U_EXPORT2
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
UChar *keyword, int32_t capacity,
UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
/**
* Creates a string enumeration of all plural rule keywords used in this
* UPluralRules object. The rule "other" is always present by default.
* @param uplrules The UPluralRules object specifying the rules for
* a given locale.
* @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.
* @stable ICU 59
*/
U_STABLE UEnumeration* U_EXPORT2
uplrules_getKeywords(const UPluralRules *uplrules,
UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -6,7 +6,7 @@
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: uregex.h
* encoding: US-ASCII
* encoding: UTF-8
* indentation:4
*
* created on: 2004mar09

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
@ -113,7 +113,7 @@ typedef enum URegionType {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
URGN_LIMIT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} URegionType;
#if !UCONFIG_NO_FORMATTING

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
@ -34,7 +34,7 @@
* for determining which unit to use, such as deciding between "in 7 days"
* and "in 1 week".
*
* @draft ICU 57
* @stable ICU 57
*/
/**
@ -66,104 +66,103 @@ typedef enum UDateRelativeDateTimeFormatterStyle {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UDAT_STYLE_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} UDateRelativeDateTimeFormatterStyle;
#ifndef U_HIDE_DRAFT_API
/**
* Represents the unit for formatting a relative date. e.g "in 5 days"
* or "next year"
* @draft ICU 57
* @stable ICU 57
*/
typedef enum URelativeDateTimeUnit {
/**
* Specifies that relative unit is year, e.g. "last year",
* "in 5 years".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_YEAR,
/**
* Specifies that relative unit is quarter, e.g. "last quarter",
* "in 5 quarters".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_QUARTER,
/**
* Specifies that relative unit is month, e.g. "last month",
* "in 5 months".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_MONTH,
/**
* Specifies that relative unit is week, e.g. "last week",
* "in 5 weeks".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_WEEK,
/**
* Specifies that relative unit is day, e.g. "yesterday",
* "in 5 days".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_DAY,
/**
* Specifies that relative unit is hour, e.g. "1 hour ago",
* "in 5 hours".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_HOUR,
/**
* Specifies that relative unit is minute, e.g. "1 minute ago",
* "in 5 minutes".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_MINUTE,
/**
* Specifies that relative unit is second, e.g. "1 second ago",
* "in 5 seconds".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_SECOND,
/**
* Specifies that relative unit is Sunday, e.g. "last Sunday",
* "this Sunday", "next Sunday", "in 5 Sundays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_SUNDAY,
/**
* Specifies that relative unit is Monday, e.g. "last Monday",
* "this Monday", "next Monday", "in 5 Mondays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_MONDAY,
/**
* Specifies that relative unit is Tuesday, e.g. "last Tuesday",
* "this Tuesday", "next Tuesday", "in 5 Tuesdays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_TUESDAY,
/**
* Specifies that relative unit is Wednesday, e.g. "last Wednesday",
* "this Wednesday", "next Wednesday", "in 5 Wednesdays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_WEDNESDAY,
/**
* Specifies that relative unit is Thursday, e.g. "last Thursday",
* "this Thursday", "next Thursday", "in 5 Thursdays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_THURSDAY,
/**
* Specifies that relative unit is Friday, e.g. "last Friday",
* "this Friday", "next Friday", "in 5 Fridays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_FRIDAY,
/**
* Specifies that relative unit is Saturday, e.g. "last Saturday",
* "this Saturday", "next Saturday", "in 5 Saturdays".
* @draft ICU 57
* @stable ICU 57
*/
UDAT_REL_UNIT_SATURDAY,
#ifndef U_HIDE_DEPRECATED_API
@ -172,18 +171,15 @@ typedef enum URelativeDateTimeUnit {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
UDAT_REL_UNIT_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} URelativeDateTimeUnit;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DRAFT_API
/**
* Opaque URelativeDateTimeFormatter object for use in C programs.
* @draft ICU 57
* @stable ICU 57
*/
struct URelativeDateTimeFormatter;
typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter; /**< C typedef for struct URelativeDateTimeFormatter. @draft ICU 57 */
typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter; /**< C typedef for struct URelativeDateTimeFormatter. @stable ICU 57 */
/**
@ -216,9 +212,9 @@ typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter; /**< C ty
* @return
* A pointer to a URelativeDateTimeFormatter object for the specified locale,
* or NULL if an error occurred.
* @draft ICU 57
* @stable ICU 57
*/
U_DRAFT URelativeDateTimeFormatter* U_EXPORT2
U_STABLE URelativeDateTimeFormatter* U_EXPORT2
ureldatefmt_open( const char* locale,
UNumberFormat* nfToAdopt,
UDateRelativeDateTimeFormatterStyle width,
@ -229,9 +225,9 @@ ureldatefmt_open( const char* locale,
* Close a URelativeDateTimeFormatter object. Once closed it may no longer be used.
* @param reldatefmt
* The URelativeDateTimeFormatter object to close.
* @draft ICU 57
* @stable ICU 57
*/
U_DRAFT void U_EXPORT2
U_STABLE void U_EXPORT2
ureldatefmt_close(URelativeDateTimeFormatter *reldatefmt);
#if U_SHOW_CPLUSPLUS_API
@ -245,7 +241,7 @@ U_NAMESPACE_BEGIN
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 57
* @stable ICU 57
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalURelativeDateTimeFormatterPointer, URelativeDateTimeFormatter, ureldatefmt_close);
@ -279,9 +275,9 @@ U_NAMESPACE_END
* @return
* The length of the formatted result; may be greater
* than resultCapacity, in which case an error is returned.
* @draft ICU 57
* @stable ICU 57
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
@ -315,9 +311,9 @@ ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
* @return
* The length of the formatted result; may be greater
* than resultCapacity, in which case an error is returned.
* @draft ICU 57
* @stable ICU 57
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
@ -352,9 +348,9 @@ ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
* @return
* The length of the formatted result; may be greater than resultCapacity,
* in which case an error is returned.
* @draft ICU 57
* @stable ICU 57
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
const UChar * relativeDateString,
int32_t relativeDateStringLen,
@ -364,8 +360,6 @@ ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
int32_t resultCapacity,
UErrorCode* status );
#endif /* U_HIDE_DRAFT_API */
#endif /* !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION */
#endif

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -196,7 +196,7 @@ typedef enum {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
USEARCH_ATTRIBUTE_COUNT = 3
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} USearchAttribute;
/**
@ -257,10 +257,9 @@ typedef enum {
* match an e with the same diacritic or a plain e in the searched text.
*
* This option is similar to "asymmetric search" as described in
* <a href="http://www.unicode.org/reports/tr10/#Asymmetric_Search">
* UTS #10 Unicode Collation Algorithm</a, but also allows unmarked
* characters in the searched text to match marked or unmarked versions of
* that character in the pattern.
* [UTS #10 Unicode Collation Algorithm](http://www.unicode.org/reports/tr10/#Asymmetric_Search),
* but also allows unmarked characters in the searched text to match
* marked or unmarked versions of that character in the pattern.
*
* @stable ICU 4.4
*/
@ -272,7 +271,7 @@ typedef enum {
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
USEARCH_ATTRIBUTE_VALUE_COUNT
#endif // U_HIDE_DEPRECATED_API
#endif /* U_HIDE_DEPRECATED_API */
} USearchAttributeValue;
/* open and close ------------------------------------------------------ */

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
***************************************************************************
@ -6,7 +6,7 @@
* and others. All Rights Reserved.
***************************************************************************
* file name: uspoof.h
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@ -94,7 +94,6 @@
* // ...
* \endcode
*
* <p>
* UTS 39 defines two strings to be <em>confusable</em> if they map to the same <em>skeleton string</em>. A skeleton can
* be thought of as a "hash code". {@link uspoof_getSkeleton} computes the skeleton for a particular string, so
* the following snippet is equivalent to the example above:
@ -128,7 +127,6 @@
* free(skel2);
* \endcode
*
* <p>
* If you need to check if a string is confusable with any string in a dictionary of many strings, rather than calling
* {@link uspoof_areConfusable} many times in a loop, {@link uspoof_getSkeleton} can be used instead, as shown below:
*
@ -172,14 +170,12 @@
* uspoof_close(sc);
* \endcode
*
* <p>
* <b>Note:</b> Since the Unicode confusables mapping table is frequently updated, confusable skeletons are <em>not</em>
* guaranteed to be the same between ICU releases. We therefore recommend that you always compute confusable skeletons
* at runtime and do not rely on creating a permanent, or difficult to update, database of skeletons.
*
* <h2>Spoof Detection</h2>
*
* <p>
* The following snippet shows a minimal example of using <code>USpoofChecker</code> to perform spoof detection on a
* string:
*
@ -204,16 +200,13 @@
* uset_close(allowed);
* \endcode
*
* <p>
* As in the case for confusability checking, it is good practice to create one <code>USpoofChecker</code> instance at
* startup, and call the cheaper {@link uspoof_check} online. We specify the set of
* allowed characters to be those with type RECOMMENDED or INCLUSION, according to the recommendation in UTS 39.
*
* <p>
* In addition to {@link uspoof_check}, the function {@link uspoof_checkUTF8} is exposed for UTF8-encoded char* strings,
* and {@link uspoof_checkUnicodeString} is exposed for C++ programmers.
*
* <p>
* If the {@link USPOOF_AUX_INFO} check is enabled, a limited amount of information on why a string failed the checks
* is available in the returned bitmask. For complete information, use the {@link uspoof_check2} class of functions
* with a {@link USpoofCheckResult} parameter:
@ -274,7 +267,6 @@
* // Explicit cleanup not necessary.
* \endcode
*
* <p>
* The return value is a bitmask of the checks that failed. In this case, there was one check that failed:
* {@link USPOOF_RESTRICTION_LEVEL}, corresponding to the fifth bit (16). The possible checks are:
*
@ -307,7 +299,6 @@
* uspoof_close(sc);
* \endcode
*
* <p>
* Here is an example in C++ showing how to compute the restriction level of a string:
*
* \code{.cpp}
@ -334,11 +325,9 @@
* printf("Restriction level: %#010x (status: %s)\n", restrictionLevel, u_errorName(status));
* \endcode
*
* <p>
* The code '0x50000000' corresponds to the restriction level USPOOF_MINIMALLY_RESTRICTIVE. Since
* USPOOF_MINIMALLY_RESTRICTIVE is weaker than USPOOF_MODERATELY_RESTRICTIVE, the string fails the check.
*
* <p>
* <b>Note:</b> The Restriction Level is the most powerful of the checks. The full logic is documented in
* <a href="http://unicode.org/reports/tr39/#Restriction_Level_Detection">UTS 39</a>, but the basic idea is that strings
* are restricted to contain characters from only a single script, <em>except</em> that most scripts are allowed to have
@ -352,15 +341,12 @@
*
* <h2>Additional Information</h2>
*
* <p>
* A <code>USpoofChecker</code> instance may be used repeatedly to perform checks on any number of identifiers.
*
* <p>
* <b>Thread Safety:</b> The test functions for checking a single identifier, or for testing whether
* two identifiers are possible confusable, are thread safe. They may called concurrently, from multiple threads,
* using the same USpoofChecker instance.
*
* <p>
* More generally, the standard ICU thread safety rules apply: functions that take a const USpoofChecker parameter are
* thread safe. Those that take a non-const USpoofChecker are not thread safe..
*
@ -368,18 +354,17 @@
*/
struct USpoofChecker;
/**
* @stable ICU 4.2
*/
typedef struct USpoofChecker USpoofChecker; /**< typedef for C of USpoofChecker */
#ifndef U_HIDE_DRAFT_API
/**
* @see uspoof_openCheckResult
*/
struct USpoofCheckResult;
/**
* @see uspoof_openCheckResult
* @stable ICU 58
*/
typedef struct USpoofCheckResult USpoofCheckResult;
#endif /* U_HIDE_DRAFT_API */
/**
* Enum for the kinds of checks that USpoofChecker can perform.
@ -419,7 +404,6 @@ typedef enum USpoofChecks {
*/
USPOOF_WHOLE_SCRIPT_CONFUSABLE = 4,
#ifndef U_HIDE_DRAFT_API
/**
* Enable this flag in {@link uspoof_setChecks} to turn on all types of confusables. You may set
* the checks to some subset of SINGLE_SCRIPT_CONFUSABLE, MIXED_SCRIPT_CONFUSABLE, or WHOLE_SCRIPT_CONFUSABLE to
@ -427,10 +411,9 @@ typedef enum USpoofChecks {
*
* @see uspoof_areConfusable
* @see uspoof_getSkeleton
* @draft ICU 58
* @stable ICU 58
*/
USPOOF_CONFUSABLE = USPOOF_SINGLE_SCRIPT_CONFUSABLE | USPOOF_MIXED_SCRIPT_CONFUSABLE | USPOOF_WHOLE_SCRIPT_CONFUSABLE,
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DEPRECATED_API
/**
@ -480,7 +463,7 @@ typedef enum USpoofChecks {
*/
USPOOF_CHAR_LIMIT = 64,
/**
/**
* Check that an identifier does not mix numbers from different numbering systems.
* For more information, see UTS 39 section 5.3.
*
@ -488,6 +471,29 @@ typedef enum USpoofChecks {
*/
USPOOF_MIXED_NUMBERS = 128,
#ifndef U_HIDE_DRAFT_API
/**
* Check that an identifier does not have a combining character following a character in which that
* combining character would be hidden; for example 'i' followed by a U+0307 combining dot.
*
* More specifically, the following characters are forbidden from preceding a U+0307:
* <ul>
* <li>Those with the Soft_Dotted Unicode property (which includes 'i' and 'j')</li>
* <li>Latin lowercase letter 'l'</li>
* <li>Dotless 'i' and 'j' ('ı' and 'ȷ', U+0131 and U+0237)</li>
* <li>Any character whose confusable prototype ends with such a character
* (Soft_Dotted, 'l', 'ı', or 'ȷ')</li>
* </ul>
* In addition, combining characters are allowed between the above characters and U+0307 except those
* with combining class 0 or combining class "Above" (230, same class as U+0307).
*
* This list and the number of combing characters considered by this check may grow over time.
*
* @draft ICU 62
*/
USPOOF_HIDDEN_OVERLAY = 256,
#endif /* U_HIDE_DRAFT_API */
/**
* Enable all spoof checks.
*
@ -1058,7 +1064,6 @@ uspoof_checkUnicodeString(const USpoofChecker *sc,
#endif
#ifndef U_HIDE_DRAFT_API
/**
* Check the specified string for possible security issues.
* The text to be checked will typically be an identifier of some sort.
@ -1085,9 +1090,9 @@ uspoof_checkUnicodeString(const USpoofChecker *sc,
* @see uspoof_openCheckResult
* @see uspoof_check2UTF8
* @see uspoof_check2UnicodeString
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
uspoof_check2(const USpoofChecker *sc,
const UChar* id, int32_t length,
USpoofCheckResult* checkResult,
@ -1122,9 +1127,9 @@ uspoof_check2(const USpoofChecker *sc,
* @see uspoof_openCheckResult
* @see uspoof_check2
* @see uspoof_check2UnicodeString
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
uspoof_check2UTF8(const USpoofChecker *sc,
const char *id, int32_t length,
USpoofCheckResult* checkResult,
@ -1154,9 +1159,9 @@ uspoof_check2UTF8(const USpoofChecker *sc,
* @see uspoof_openCheckResult
* @see uspoof_check2
* @see uspoof_check2UTF8
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
uspoof_check2UnicodeString(const USpoofChecker *sc,
const icu::UnicodeString &id,
USpoofCheckResult* checkResult,
@ -1179,9 +1184,9 @@ uspoof_check2UnicodeString(const USpoofChecker *sc,
* @see uspoof_check2
* @see uspoof_check2UTF8
* @see uspoof_check2UnicodeString
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT USpoofCheckResult* U_EXPORT2
U_STABLE USpoofCheckResult* U_EXPORT2
uspoof_openCheckResult(UErrorCode *status);
/**
@ -1189,9 +1194,9 @@ uspoof_openCheckResult(UErrorCode *status);
* its implementation.
*
* @param checkResult The instance of USpoofCheckResult to close
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT void U_EXPORT2
U_STABLE void U_EXPORT2
uspoof_closeCheckResult(USpoofCheckResult *checkResult);
#if U_SHOW_CPLUSPLUS_API
@ -1200,14 +1205,21 @@ U_NAMESPACE_BEGIN
/**
* \class LocalUSpoofCheckResultPointer
* "Smart pointer" class, closes a USpoofCheckResult via {@link uspoof_closeCheckResult}.
* "Smart pointer" class, closes a USpoofCheckResult via `uspoof_closeCheckResult()`.
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 58
* @stable ICU 58
*/
/**
* \cond
* Note: Doxygen is giving a bogus warning on this U_DEFINE_LOCAL_OPEN_POINTER.
* For now, suppress with a Doxygen cond
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult);
/** \endcond */
U_NAMESPACE_END
@ -1225,9 +1237,9 @@ U_NAMESPACE_END
* will be zero if the input string passes all of the
* enabled checks.
* @see uspoof_setChecks
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status);
/**
@ -1238,9 +1250,9 @@ uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *st
* @param status The error code, set if an error occurred.
* @return The restriction level contained in the USpoofCheckResult
* @see uspoof_setRestrictionLevel
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT URestrictionLevel U_EXPORT2
U_STABLE URestrictionLevel U_EXPORT2
uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErrorCode *status);
/**
@ -1252,11 +1264,10 @@ uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErr
* @param checkResult The instance of USpoofCheckResult created by {@link uspoof_openCheckResult}
* @return The set of numerics contained in the USpoofCheckResult
* @param status The error code, set if an error occurred.
* @draft ICU 58
* @stable ICU 58
*/
U_DRAFT const USet* U_EXPORT2
U_STABLE const USet* U_EXPORT2
uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status);
#endif /* U_HIDE_DRAFT_API */
/**

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -283,10 +283,14 @@ typedef enum UDateTimeScale {
*/
UDTS_UNIX_MICROSECONDS_TIME,
#ifndef U_HIDE_DEPRECATED_API
/**
* The first unused time scale value. The limit of this enum
* @deprecated ICU 59 The numeric value may change over time, see ICU ticket #12420.
*/
UDTS_MAX_SCALE
#endif /* U_HIDE_DEPRECATED_API */
} UDateTimeScale;
/**
@ -423,12 +427,15 @@ typedef enum UTimeScaleValue {
#endif /* U_HIDE_INTERNAL_API */
#ifndef U_HIDE_DEPRECATED_API
/**
* The number of time scale values, in other words limit of this enum.
*
* @see utmscale_getTimeScaleValue
* @deprecated ICU 59 The numeric value may change over time, see ICU ticket #12420.
*/
UTSV_MAX_SCALE_VALUE=11
#endif /* U_HIDE_DEPRECATED_API */
} UTimeScaleValue;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -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);

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************