ICU-20164 Make NoUnit a zero-cost abstraction over MeasureUnit.

See #1230
This commit is contained in:
Shane F. Carr 2020-08-28 19:26:55 +00:00
parent 35eae09a7c
commit 0101e2632c
22 changed files with 269 additions and 364 deletions

View File

@ -193,7 +193,6 @@
<ClCompile Include="nfrs.cpp" />
<ClCompile Include="nfrule.cpp" />
<ClCompile Include="nfsubs.cpp" />
<ClCompile Include="nounit.cpp" />
<ClCompile Include="number_affixutils.cpp" />
<ClCompile Include="number_asformat.cpp" />
<ClCompile Include="number_compact.cpp" />

View File

@ -531,9 +531,6 @@
<ClCompile Include="uregion.cpp">
<Filter>formatting</Filter>
</ClCompile>
<ClCompile Include="nounit.cpp">
<Filter>misc</Filter>
</ClCompile>
<ClCompile Include="number_affixutils.cpp">
<Filter>formatting</Filter>
</ClCompile>

View File

@ -414,7 +414,6 @@
<ClCompile Include="nfrs.cpp" />
<ClCompile Include="nfrule.cpp" />
<ClCompile Include="nfsubs.cpp" />
<ClCompile Include="nounit.cpp" />
<ClCompile Include="number_affixutils.cpp" />
<ClCompile Include="number_asformat.cpp" />
<ClCompile Include="number_compact.cpp" />

View File

@ -2266,15 +2266,6 @@ void MeasureUnit::initCurrency(StringPiece isoCurrency) {
fSubTypeId = result - gOffsets[fTypeId];
}
void MeasureUnit::initNoUnit(const char *subtype) {
int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "none");
U_ASSERT(result != -1);
fTypeId = result;
result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], subtype);
U_ASSERT(result != -1);
fSubTypeId = result - gOffsets[fTypeId];
}
void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
fTypeId = typeId;
fSubTypeId = subTypeId;

View File

@ -1,42 +0,0 @@
// © 2017 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "unicode/nounit.h"
#include "uassert.h"
#if !UCONFIG_NO_FORMATTING
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NoUnit)
NoUnit U_EXPORT2 NoUnit::base() {
return NoUnit("");
}
NoUnit U_EXPORT2 NoUnit::percent() {
return NoUnit("percent");
}
NoUnit U_EXPORT2 NoUnit::permille() {
return NoUnit("permille");
}
NoUnit::NoUnit(const char* subtype) {
initNoUnit(subtype);
}
NoUnit::NoUnit(const NoUnit& other) : MeasureUnit(other) {
}
NoUnit* NoUnit::clone() const {
return new NoUnit(*this);
}
NoUnit::~NoUnit() {
}
U_NAMESPACE_END
#endif

View File

@ -130,7 +130,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Pre-compute a few values for efficiency.
bool isCurrency = utils::unitIsCurrency(macros.unit);
bool isNoUnit = utils::unitIsNoUnit(macros.unit);
bool isBaseUnit = utils::unitIsBaseUnit(macros.unit);
bool isPercent = utils::unitIsPercent(macros.unit);
bool isPermille = utils::unitIsPermille(macros.unit);
bool isAccounting =
@ -144,7 +144,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
if (macros.unitWidth != UNUM_UNIT_WIDTH_COUNT) {
unitWidth = macros.unitWidth;
}
bool isCldrUnit = !isCurrency && !isNoUnit &&
bool isCldrUnit = !isCurrency && !isBaseUnit &&
(unitWidth == UNUM_UNIT_WIDTH_FULL_NAME || !(isPercent || isPermille));
// Select the numbering system.

View File

@ -189,14 +189,11 @@ Notation stem_to_object::notation(skeleton::StemEnum stem) {
MeasureUnit stem_to_object::unit(skeleton::StemEnum stem) {
switch (stem) {
case STEM_BASE_UNIT:
// Slicing is okay
return NoUnit::base(); // NOLINT
return MeasureUnit();
case STEM_PERCENT:
// Slicing is okay
return NoUnit::percent(); // NOLINT
return MeasureUnit::getPercent();
case STEM_PERMILLE:
// Slicing is okay
return NoUnit::permille(); // NOLINT
return MeasureUnit::getPermille();
default:
UPRV_UNREACHABLE;
}
@ -1521,17 +1518,15 @@ bool GeneratorHelpers::unit(const MacroProps& macros, UnicodeString& sb, UErrorC
}
blueprint_helpers::generateCurrencyOption(currency, sb, status);
return true;
} else if (utils::unitIsNoUnit(macros.unit)) {
if (utils::unitIsPercent(macros.unit)) {
sb.append(u"percent", -1);
return true;
} else if (utils::unitIsPermille(macros.unit)) {
sb.append(u"permille", -1);
return true;
} else {
// Default value is not shown in normalized form
return false;
}
} else if (utils::unitIsBaseUnit(macros.unit)) {
// Default value is not shown in normalized form
return false;
} else if (utils::unitIsPercent(macros.unit)) {
sb.append(u"percent", -1);
return true;
} else if (utils::unitIsPermille(macros.unit)) {
sb.append(u"permille", -1);
return true;
} else {
sb.append(u"measure-unit/", -1);
blueprint_helpers::generateMeasureUnitOption(macros.unit, sb, status);
@ -1541,14 +1536,9 @@ bool GeneratorHelpers::unit(const MacroProps& macros, UnicodeString& sb, UErrorC
bool GeneratorHelpers::perUnit(const MacroProps& macros, UnicodeString& sb, UErrorCode& status) {
// Per-units are currently expected to be only MeasureUnits.
if (utils::unitIsNoUnit(macros.perUnit)) {
if (utils::unitIsPercent(macros.perUnit) || utils::unitIsPermille(macros.perUnit)) {
status = U_UNSUPPORTED_ERROR;
return false;
} else {
// Default value: ok to ignore
return false;
}
if (utils::unitIsBaseUnit(macros.perUnit)) {
// Default value: ok to ignore
return false;
} else if (utils::unitIsCurrency(macros.perUnit)) {
status = U_UNSUPPORTED_ERROR;
return false;

View File

@ -49,8 +49,8 @@ inline bool unitIsCurrency(const MeasureUnit& unit) {
return uprv_strcmp("currency", unit.getType()) == 0;
}
inline bool unitIsNoUnit(const MeasureUnit& unit) {
return uprv_strcmp("none", unit.getType()) == 0;
inline bool unitIsBaseUnit(const MeasureUnit& unit) {
return unit == MeasureUnit();
}
inline bool unitIsPercent(const MeasureUnit& unit) {

View File

@ -97,7 +97,6 @@ nfrs.cpp
nfrule.cpp
nfsubs.cpp
nortrans.cpp
nounit.cpp
nultrans.cpp
number_affixutils.cpp
number_asformat.cpp

View File

@ -3353,12 +3353,6 @@ class U_I18N_API MeasureUnit: public UObject {
*/
void initCurrency(StringPiece isoCurrency);
/**
* For ICU use only.
* @internal
*/
void initNoUnit(const char *subtype);
#endif /* U_HIDE_INTERNAL_API */
private:

View File

@ -29,80 +29,53 @@ U_NAMESPACE_BEGIN
/**
* Dimensionless unit for percent and permille.
* Prior to ICU 68, this namespace was a class with the same name.
* @see NumberFormatter
* @draft ICU 60
* @draft ICU 68
*/
class U_I18N_API NoUnit: public MeasureUnit {
public:
namespace NoUnit {
/**
* Returns an instance for the base unit (dimensionless and no scaling).
*
* @return a NoUnit instance
* @draft ICU 60
* Prior to ICU 68, this function returned a NoUnit by value.
*
* Since ICU 68, this function returns the same value as the default MeasureUnit constructor.
*
* @return a MeasureUnit instance
* @draft ICU 68
*/
static NoUnit U_EXPORT2 base();
static inline MeasureUnit U_EXPORT2 base() {
return MeasureUnit();
}
/**
* Returns an instance for percent, or 1/100 of a base unit.
*
* @return a NoUnit instance
* @draft ICU 60
* Prior to ICU 68, this function returned a NoUnit by value.
*
* Since ICU 68, this function returns the same value as MeasureUnit::getPercent().
*
* @return a MeasureUnit instance
* @draft ICU 68
*/
static NoUnit U_EXPORT2 percent();
static inline MeasureUnit U_EXPORT2 percent() {
return MeasureUnit::getPercent();
}
/**
* Returns an instance for permille, or 1/1000 of a base unit.
*
* @return a NoUnit instance
* @draft ICU 60
* Prior to ICU 68, this function returned a NoUnit by value.
*
* Since ICU 68, this function returns the same value as MeasureUnit::getPermille().
*
* @return a MeasureUnit instance
* @draft ICU 68
*/
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 NoUnit* 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);
};
static inline MeasureUnit U_EXPORT2 permille() {
return MeasureUnit::getPermille();
}
}
U_NAMESPACE_END

View File

@ -1373,10 +1373,10 @@ struct U_I18N_API MacroProps : public UMemory {
Notation notation;
/** @internal */
MeasureUnit unit; // = NoUnit::base();
MeasureUnit unit; // = MeasureUnit(); (the base dimensionless unit)
/** @internal */
MeasureUnit perUnit; // = NoUnit::base();
MeasureUnit perUnit; // = MeasureUnit(); (the base dimensionless unit)
/** @internal */
Precision precision; // = Precision(); (bogus)

View File

@ -1068,7 +1068,7 @@ group: units_extra
units bytestriebuilder bytestrie resourcebundle uclean_i18n
group: units
measunit.o currunit.o nounit.o
measunit.o currunit.o
deps
stringenumeration errorcode

View File

@ -1013,6 +1013,18 @@ void NumberFormatterApiTest::unitPercent() {
Locale::getEnglish(),
-98.7654321,
u"-98.765432%");
assertFormatSingle(
u"Per Percent",
u"measure-unit/length-meter per-measure-unit/concentr-percent unit-width-full-name",
u"measure-unit/length-meter per-measure-unit/concentr-percent unit-width-full-name",
NumberFormatter::with()
.unit(MeasureUnit::getMeter())
.perUnit(MeasureUnit::getPercent())
.unitWidth(UNUM_UNIT_WIDTH_FULL_NAME),
Locale::getEnglish(),
50,
u"50 meters per percent");
}
void NumberFormatterApiTest::percentParity() {

View File

@ -276,7 +276,6 @@ UObject *UObjectTest::testClassNoClassID(UObject *obj, const char *className, co
#include "unicode/msgfmt.h"
#include "unicode/normlzr.h"
#include "unicode/normalizer2.h"
#include "unicode/nounit.h"
#include "unicode/numfmt.h"
#include "unicode/parsepos.h"
#include "unicode/plurrule.h"
@ -373,7 +372,6 @@ void UObjectTest::testIDs()
TESTCLASSID_DEFAULT(Formattable);
TESTCLASSID_FACTORY(MeasureUnit, MeasureUnit::createMeter(status));
TESTCLASSID_FACTORY(NoUnit, NoUnit::percent().clone());
TESTCLASSID_FACTORY(TimeUnit, TimeUnit::createInstance(TimeUnit::UTIMEUNIT_YEAR, status));
static const UChar SMALL_STR[] = u"QQQ";
TESTCLASSID_CTOR(CurrencyAmount, (1.0, SMALL_STR, status));

View File

@ -17,17 +17,17 @@ compact-short percent unit-width-narrow
compact-short percent unit-width-full-name
es-MX
0 %
92 k
-0.22 %
0 por ciento
92 k por ciento
-0.22 por ciento
zh-TW
0%
9.2萬
9.2萬%
-0.22%
bn-BD
%
৯২ হা
-.২২%
শতাংশ
৯২ হাশতাংশ
-.২২শতাংশ
compact-short currency/EUR unit-width-narrow
es-MX
@ -101,17 +101,17 @@ scientific/+ee/sign-always percent unit-width-narrow
scientific/+ee/sign-always percent unit-width-full-name
es-MX
0E+00 %
9.182736E+04 %
-2.2222E-01 %
0E+00 por ciento
9.182736E+04 por ciento
-2.2222E-01 por ciento
zh-TW
0E+00%
9.182736E+04%
-2.2222E-01%
bn-BD
E+%
৯.১৮২৩৬E+%
-২.২২২২E-০১%
E+শতাংশ
৯.১৮২৩৬E+শতাংশ
-২.২২২২E-০১শতাংশ
scientific/+ee/sign-always currency/EUR unit-width-narrow
es-MX
@ -3139,59 +3139,59 @@ percent unit-width-narrow @@
percent unit-width-full-name precision-integer
es-MX
0 %
91,827 %
-0 %
0 por ciento
91,827 por ciento
-0 por ciento
zh-TW
0%
91,827%
-0%
bn-BD
%
৯১,৮২৭%
-%
শতাংশ
৯১,৮২৭শতাংশ
-শতাংশ
percent unit-width-full-name .000
es-MX
0.000 %
91,827.364 %
-0.222 %
0.000 por ciento
91,827.364 por ciento
-0.222 por ciento
zh-TW
0.000%
91,827.364%
-0.222%
bn-BD
.%
৯১,৮২৭.৩৬৪%
-.২২২%
.শতাংশ
৯১,৮২৭.৩৬৪শতাংশ
-.২২২শতাংশ
percent unit-width-full-name .##/@@@+
es-MX
0 %
91,827.36 %
-0.222 %
0 por ciento
91,827.36 por ciento
-0.222 por ciento
zh-TW
0%
91,827.36%
-0.222%
bn-BD
%
৯১,৮২৭.৩৬%
-.২২২%
শতাংশ
৯১,৮২৭.৩৬শতাংশ
-.২২২শতাংশ
percent unit-width-full-name @@
es-MX
0.0 %
92,000 %
-0.22 %
0.0 por ciento
92,000 por ciento
-0.22 por ciento
zh-TW
0.0%
92,000%
-0.22%
bn-BD
.%
৯২,%
-.২২%
.শতাংশ
৯২,শতাংশ
-.২২শতাংশ
currency/EUR unit-width-narrow precision-integer
es-MX
@ -3433,17 +3433,17 @@ percent unit-width-narrow rounding-mode-floor
percent unit-width-full-name rounding-mode-floor
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow rounding-mode-floor
es-MX
@ -3517,17 +3517,17 @@ percent unit-width-narrow integer-width/##00
percent unit-width-full-name integer-width/##00
es-MX
00 %
1827.3645 %
-00.22222 %
00 por ciento
1827.3645 por ciento
-00.22222 por ciento
zh-TW
00%
1,827.3645%
-00.22222%
bn-BD
%
১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow integer-width/##00
es-MX
@ -3601,17 +3601,17 @@ percent unit-width-narrow scale/0.5
percent unit-width-full-name scale/0.5
es-MX
0 %
45,913.68225 %
-0.11111 %
0 por ciento
45,913.68225 por ciento
-0.11111 por ciento
zh-TW
0%
45,913.68225%
-0.11111%
bn-BD
%
৪৫,৯১৩.৬৮২২৫%
-.১১১১১%
শতাংশ
৪৫,৯১৩.৬৮২২৫শতাংশ
-.১১১১১শতাংশ
currency/EUR unit-width-narrow scale/0.5
es-MX
@ -3685,17 +3685,17 @@ percent unit-width-narrow group-on-aligned
percent unit-width-full-name group-on-aligned
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow group-on-aligned
es-MX
@ -3769,17 +3769,17 @@ percent unit-width-narrow latin
percent unit-width-full-name latin
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
0%
91,827.3645%
-0.22222%
0শতাংশ
91,827.3645শতাংশ
-0.22222শতাংশ
currency/EUR unit-width-narrow latin
es-MX
@ -3853,17 +3853,17 @@ percent unit-width-narrow sign-accounting-except-zero
percent unit-width-full-name sign-accounting-except-zero
es-MX
0 %
+91,827.3645 %
-0.22222 %
0 por ciento
+91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
+91,827.3645%
-0.22222%
bn-BD
%
+৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
+৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow sign-accounting-except-zero
es-MX
@ -3937,17 +3937,17 @@ percent unit-width-narrow decimal-always
percent unit-width-full-name decimal-always
es-MX
0. %
91,827.3645 %
-0.22222 %
0. por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0.%
91,827.3645%
-0.22222%
bn-BD
.%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
.শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow decimal-always
es-MX

View File

@ -146,10 +146,8 @@ class NumberFormatterImpl {
return unit != null && "currency".equals(unit.getType());
}
private static boolean unitIsNoUnit(MeasureUnit unit) {
// NOTE: In ICU4C, units cannot be null, and the default unit is a NoUnit.
// In ICU4J, return TRUE for a null unit from this method.
return unit == null || "none".equals(unit.getType());
private static boolean unitIsBaseUnit(MeasureUnit unit) {
return unit == null;
}
private static boolean unitIsPercent(MeasureUnit unit) {
@ -181,7 +179,7 @@ class NumberFormatterImpl {
// Pre-compute a few values for efficiency.
boolean isCurrency = unitIsCurrency(macros.unit);
boolean isNoUnit = unitIsNoUnit(macros.unit);
boolean isBaseUnit = unitIsBaseUnit(macros.unit);
boolean isPercent = unitIsPercent(macros.unit);
boolean isPermille = unitIsPermille(macros.unit);
boolean isAccounting = macros.sign == SignDisplay.ACCOUNTING
@ -192,7 +190,7 @@ class NumberFormatterImpl {
if (macros.unitWidth != null) {
unitWidth = macros.unitWidth;
}
boolean isCldrUnit = !isCurrency && !isNoUnit &&
boolean isCldrUnit = !isCurrency && !isBaseUnit &&
(unitWidth == UnitWidth.FULL_NAME || !(isPercent || isPermille));
PluralRules rules = macros.rules;

View File

@ -1436,18 +1436,12 @@ class NumberSkeletonImpl {
sb.append("currency/");
BlueprintHelpers.generateCurrencyOption((Currency) macros.unit, sb);
return true;
} else if (macros.unit instanceof NoUnit) {
if (macros.unit == NoUnit.PERCENT) {
sb.append("percent");
return true;
} else if (macros.unit == NoUnit.PERMILLE) {
sb.append("permille");
return true;
} else {
assert macros.unit == NoUnit.BASE;
// Default value is not shown in normalized form
return false;
}
} else if (macros.unit == MeasureUnit.PERCENT) {
sb.append("percent");
return true;
} else if (macros.unit == MeasureUnit.PERMILLE) {
sb.append("permille");
return true;
} else {
sb.append("measure-unit/");
BlueprintHelpers.generateMeasureUnitOption(macros.unit, sb);
@ -1457,7 +1451,7 @@ class NumberSkeletonImpl {
private static boolean perUnit(MacroProps macros, StringBuilder sb) {
// Per-units are currently expected to be only MeasureUnits.
if (macros.perUnit instanceof Currency || macros.perUnit instanceof NoUnit) {
if (macros.perUnit instanceof Currency) {
throw new UnsupportedOperationException(
"Cannot generate number skeleton with per-unit that is not a standard measure unit");
} else {

View File

@ -197,8 +197,6 @@ public class MeasureUnit implements Serializable {
factory = CURRENCY_FACTORY;
} else if ("duration".equals(type)) {
factory = TIMEUNIT_FACTORY;
} else if ("none".equals(type)) {
factory = NOUNIT_FACTORY;
} else {
factory = UNIT_FACTORY;
}
@ -294,13 +292,6 @@ public class MeasureUnit implements Serializable {
}
};
static Factory NOUNIT_FACTORY = new Factory() {
@Override
public MeasureUnit create(String type, String subType) {
return new NoUnit(subType);
}
};
/**
* Sink for enumerating the available measure units.
*/

View File

@ -7,47 +7,46 @@ import com.ibm.icu.number.NumberFormatter;
/**
* Dimensionless unit for percent and permille.
* @see NumberFormatter
* @draft ICU 60
* @draft ICU 68
* @provisional This API might change or be removed in a future release.
*/
public class NoUnit extends MeasureUnit {
private static final long serialVersionUID = 2467174286237024095L;
public final class NoUnit {
/**
* Constant for the base unit (dimensionless and no scaling).
*
* @draft ICU 60
* Prior to ICU 68, this constant equaled an instance of NoUnit.
*
* Since ICU 68, this constant equals null.
*
* @draft ICU 68
* @provisional This API might change or be removed in a future release.
*/
public static final NoUnit BASE =
(NoUnit) MeasureUnit.internalGetInstance("none", "base");
public static final MeasureUnit BASE = null;
/**
* Constant for the percent unit, or 1/100 of a base unit.
*
* @draft ICU 60
* Prior to ICU 68, this constant equaled an instance of NoUnit.
*
* Since ICU 68, this constant is equivalent to MeasureUnit.PERCENT.
*
* @draft ICU 68
* @provisional This API might change or be removed in a future release.
*/
public static final NoUnit PERCENT =
(NoUnit) MeasureUnit.internalGetInstance("none", "percent");
public static final MeasureUnit PERCENT = MeasureUnit.PERCENT;
/**
* Constant for the permille unit, or 1/100 of a base unit.
*
* @draft ICU 60
* Prior to ICU 68, this constant equaled an instance of NoUnit.
*
* Since ICU 68, this constant is equivalent to MeasureUnit.PERMILLE.
*
* @draft ICU 68
* @provisional This API might change or be removed in a future release.
*/
public static final NoUnit PERMILLE =
(NoUnit) MeasureUnit.internalGetInstance("none", "permille");
public static final MeasureUnit PERMILLE = MeasureUnit.PERMILLE;
/**
* Package local constructor. This class is not designed for subclassing
* by ICU users.
*
* @param subType The unit subtype.
*/
NoUnit(String subType) {
super("none", subType);
}
// This class is a namespace not intended to be instantiated:
private NoUnit() {}
}

View File

@ -17,17 +17,17 @@ compact-short percent unit-width-narrow
compact-short percent unit-width-full-name
es-MX
0 %
92 k
-0.22 %
0 por ciento
92 k por ciento
-0.22 por ciento
zh-TW
0%
9.2萬
9.2萬%
-0.22%
bn-BD
%
৯২ হা
-.২২%
শতাংশ
৯২ হাশতাংশ
-.২২শতাংশ
compact-short currency/EUR unit-width-narrow
es-MX
@ -101,17 +101,17 @@ scientific/+ee/sign-always percent unit-width-narrow
scientific/+ee/sign-always percent unit-width-full-name
es-MX
0E+00 %
9.182736E+04 %
-2.2222E-01 %
0E+00 por ciento
9.182736E+04 por ciento
-2.2222E-01 por ciento
zh-TW
0E+00%
9.182736E+04%
-2.2222E-01%
bn-BD
E+%
৯.১৮২৩৬E+%
-২.২২২২E-০১%
E+শতাংশ
৯.১৮২৩৬E+শতাংশ
-২.২২২২E-০১শতাংশ
scientific/+ee/sign-always currency/EUR unit-width-narrow
es-MX
@ -3139,59 +3139,59 @@ percent unit-width-narrow @@
percent unit-width-full-name precision-integer
es-MX
0 %
91,827 %
-0 %
0 por ciento
91,827 por ciento
-0 por ciento
zh-TW
0%
91,827%
-0%
bn-BD
%
৯১,৮২৭%
-%
শতাংশ
৯১,৮২৭শতাংশ
-শতাংশ
percent unit-width-full-name .000
es-MX
0.000 %
91,827.364 %
-0.222 %
0.000 por ciento
91,827.364 por ciento
-0.222 por ciento
zh-TW
0.000%
91,827.364%
-0.222%
bn-BD
.%
৯১,৮২৭.৩৬৪%
-.২২২%
.শতাংশ
৯১,৮২৭.৩৬৪শতাংশ
-.২২২শতাংশ
percent unit-width-full-name .##/@@@+
es-MX
0 %
91,827.36 %
-0.222 %
0 por ciento
91,827.36 por ciento
-0.222 por ciento
zh-TW
0%
91,827.36%
-0.222%
bn-BD
%
৯১,৮২৭.৩৬%
-.২২২%
শতাংশ
৯১,৮২৭.৩৬শতাংশ
-.২২২শতাংশ
percent unit-width-full-name @@
es-MX
0.0 %
92,000 %
-0.22 %
0.0 por ciento
92,000 por ciento
-0.22 por ciento
zh-TW
0.0%
92,000%
-0.22%
bn-BD
.%
৯২,%
-.২২%
.শতাংশ
৯২,শতাংশ
-.২২শতাংশ
currency/EUR unit-width-narrow precision-integer
es-MX
@ -3433,17 +3433,17 @@ percent unit-width-narrow rounding-mode-floor
percent unit-width-full-name rounding-mode-floor
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow rounding-mode-floor
es-MX
@ -3517,17 +3517,17 @@ percent unit-width-narrow integer-width/##00
percent unit-width-full-name integer-width/##00
es-MX
00 %
1827.3645 %
-00.22222 %
00 por ciento
1827.3645 por ciento
-00.22222 por ciento
zh-TW
00%
1,827.3645%
-00.22222%
bn-BD
%
১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow integer-width/##00
es-MX
@ -3601,17 +3601,17 @@ percent unit-width-narrow scale/0.5
percent unit-width-full-name scale/0.5
es-MX
0 %
45,913.68225 %
-0.11111 %
0 por ciento
45,913.68225 por ciento
-0.11111 por ciento
zh-TW
0%
45,913.68225%
-0.11111%
bn-BD
%
৪৫,৯১৩.৬৮২২৫%
-.১১১১১%
শতাংশ
৪৫,৯১৩.৬৮২২৫শতাংশ
-.১১১১১শতাংশ
currency/EUR unit-width-narrow scale/0.5
es-MX
@ -3685,17 +3685,17 @@ percent unit-width-narrow group-on-aligned
percent unit-width-full-name group-on-aligned
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow group-on-aligned
es-MX
@ -3769,17 +3769,17 @@ percent unit-width-narrow latin
percent unit-width-full-name latin
es-MX
0 %
91,827.3645 %
-0.22222 %
0 por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
91,827.3645%
-0.22222%
bn-BD
0%
91,827.3645%
-0.22222%
0শতাংশ
91,827.3645শতাংশ
-0.22222শতাংশ
currency/EUR unit-width-narrow latin
es-MX
@ -3853,17 +3853,17 @@ percent unit-width-narrow sign-accounting-except-zero
percent unit-width-full-name sign-accounting-except-zero
es-MX
0 %
+91,827.3645 %
-0.22222 %
0 por ciento
+91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0%
+91,827.3645%
-0.22222%
bn-BD
%
+৯১,৮২৭.৩৬৪৫%
-.২২২২২%
শতাংশ
+৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow sign-accounting-except-zero
es-MX
@ -3937,17 +3937,17 @@ percent unit-width-narrow decimal-always
percent unit-width-full-name decimal-always
es-MX
0. %
91,827.3645 %
-0.22222 %
0. por ciento
91,827.3645 por ciento
-0.22222 por ciento
zh-TW
0.%
91,827.3645%
-0.22222%
bn-BD
.%
৯১,৮২৭.৩৬৪৫%
-.২২২২২%
.শতাংশ
৯১,৮২৭.৩৬৪৫শতাংশ
-.২২২২২শতাংশ
currency/EUR unit-width-narrow decimal-always
es-MX

View File

@ -966,6 +966,19 @@ public class NumberFormatterApiTest {
ULocale.ENGLISH,
-98.7654321,
"-98.765432%");
assertFormatSingle(
"Per Percent",
"measure-unit/length-meter per-measure-unit/concentr-percent unit-width-full-name",
"measure-unit/length-meter per-measure-unit/concentr-percent unit-width-full-name",
NumberFormatter.with()
.unit(MeasureUnit.METER)
.perUnit(MeasureUnit.PERCENT)
.unitWidth(UnitWidth.FULL_NAME),
ULocale.ENGLISH,
50,
"50 meters per percent");
}
@Test