This redesigns the RuleBasedNumberFormat and PluralFormat classes into static methods that replace the former implementation. The mapping old-to-new is as follows:
ICU4N.Text.RuleBasedNumberFormat
a. Rules Engine > ICU4N.Globalization.NumberFormatRules, an immutable class. The instances for SpellOut, Ordinal, Duration, and NumberingSystem are available as properties on the UNumberFormatInfo class which is returned from the UCultureInfo.NumberFormat property.
b. Format method overloads > overloads of ICU4N.FormatNumberRuleBased.ToString() and ICU4N.FormatNumberRuleBased.TryFormat(), which are also also extension methods for all built-in .NET numeric data types.
ICU4N.Text.DecimalFormatSymbols > ICU4N.Globalization.UNumberFormatInfo, which is available from the UCultureInfo.NumberFormat property.
ICU4N.Text.NFSubstitution > ICU4N.Globalization.Substitution. All subclasses have also been copied to the ICU4N.Globalization namespace with their original names to subclass the new base class.
As a stand-in for DecimalFormat, we are using the custom formatting string feature in .NET. But since the .NET formatter doesn't support all of the settings that DecimalFormat has, these have been hidden from the public API until a complete implementation of DecimalFormat is constructed.
PluralFormat is also not available publicly as the MessagePattern class will need some refactoring to avoid unnecessary heap allocations.
This functionality is also currently only available on .NET 6+.
The old ICU4J APIs have been removed from the public API for NuGet releases. They can be enabled for custom builds by setting the MSBuild property IncludeLegacyNumberFormat=true in the build. Alternatively, this API is available in the https://www.nuget.org/packages/ICU4N/60.1.0-alpha.401 package. Do note there are known issues with rounding accuracy in this implementation of DecimalFormat.
The .NET formatter does not follow the IEEE 754 spec for rounding - it rounds toward positive infinity rather than to the nearest even number. So there may be issues with rounding in this new formatter for floating point types which will be addressed when we replace DecimalFormat.
Closes #41.
This redesigns the
RuleBasedNumberFormat
andPluralFormat
classes into static methods that replace the former implementation. The mapping old-to-new is as follows:ICU4N.Text.RuleBasedNumberFormat
a. Rules Engine >ICU4N.Globalization.NumberFormatRules
, an immutable class. The instances forSpellOut
,Ordinal
,Duration
, andNumberingSystem
are available as properties on theUNumberFormatInfo
class which is returned from theUCultureInfo.NumberFormat
property. b. Format method overloads > overloads ofICU4N.FormatNumberRuleBased.ToString()
andICU4N.FormatNumberRuleBased.TryFormat()
, which are also also extension methods for all built-in .NET numeric data types.ICU4N.Text.DecimalFormatSymbols
>ICU4N.Globalization.UNumberFormatInfo
, which is available from theUCultureInfo.NumberFormat
property.ICU4N.Text.NFRule
>ICU4N.Globalization.NumberFormatRule
.ICU4N.Text.NFRuleSet
>ICU4N.Globalization.NumberFormatRuleSet
.ICU4N.Text.NFSubstitution
>ICU4N.Globalization.Substitution
. All subclasses have also been copied to theICU4N.Globalization
namespace with their original names to subclass the new base class.As a stand-in for
DecimalFormat
, we are using the custom formatting string feature in .NET. But since the .NET formatter doesn't support all of the settings thatDecimalFormat
has, these have been hidden from the public API until a complete implementation ofDecimalFormat
is constructed.PluralFormat
is also not available publicly as theMessagePattern
class will need some refactoring to avoid unnecessary heap allocations.This functionality is also currently only available on .NET 6+.
The old ICU4J APIs have been removed from the public API for NuGet releases. They can be enabled for custom builds by setting the MSBuild property
IncludeLegacyNumberFormat=true
in the build. Alternatively, this API is available in the https://www.nuget.org/packages/ICU4N/60.1.0-alpha.401 package. Do note there are known issues with rounding accuracy in this implementation ofDecimalFormat
.The .NET formatter does not follow the IEEE 754 spec for rounding - it rounds toward positive infinity rather than to the nearest even number. So there may be issues with rounding in this new formatter for floating point types which will be addressed when we replace
DecimalFormat
.