v60.1.0-alpha.402
Pre-release
Pre-release
NightOwl888
released this
02 Apr 15:42
·
38 commits
to main
since this release
Known Issues
- The
ICU4N.FormatNumberRuleBased
uses the .NET formatter and replaces the ASCII digit output with native digits of the current language. This formatter doesn't support all of the features ofDecimalFormat
. Once known issue with it is that it doesn't follow the "half even" or "round toward even" rounding as is in the IEEE 754 specfication. See TR35#Rounding. Instead it rounds "toward positive infinity". To our knowledge, this only affects behavior of floating point numbers when they are larger than the value ofInt64.MaxValue
(9,223,372,036,854,775,807; that is, hexadecimal 0x7FFFFFFFFFFFFFFF) or smaller thanInt64.MinValue
(negative 9,223,372,036,854,775,808; that is, hexadecimal 0x8000000000000000), however, there may be other cases where rounding is incorrect when plural formatting is part of the rule.
Change Log
Breaking Changes
ICU4N.Impl.ResourceKey::Substring()
: Converted from start/end to startIndex/length to match .NET conventions. Optimized to useValueStringBuilder
, whereSpan<T>
is supported.ICU4N.Impl.PluralRulesLoader
+ICU4N.Text.PluralRules
: RenamedForLocale()
>GetInstance()
to match .NET naming conventions.ICU4N.Text.NumberPresentation
: MovedNumberPresentation
enum andNumberPresentationExtensions
class from theICU4N.Text
toICU4N.Globalization
namespace. Changed the values to start with 0 instead of 1 so we have a reasonable default value in .NET.ICU4N.Globalization.UCultureInfo
: RemovedClearCachedData()
method. This is in .NET only to allow it to fetch culture settings that have changed in the underlying OS.ICU4N.Text
(DisplayContext
+DisplayContextType
+DisplayContextExtensions
): Removed from the public API since they had been previously refactored in theICU4N.Globalization
namespace asCapitalization
,DialectHandling
,DisplayLength
, andSubstituteHandling
enums and theDisplayContextOptions
class.ICU4N.Text
(NumberFormat
+DecimalFormat
+RuleBasedNumberFormat
): Removed from the public API and added anIncludeLegacyNumberFormat
build property so they can be optionally compiled for those who need these features. The plan is to port the remaining frunctionality that isn't already covered byFormatNumberRuleBased
into static APIs later.ICU4N.Globalization.Capitalization
: Added "For" prefix to the names as they were in ICU4J, since this adds clarity to their intended purpose. Also explicitly specified numeric values ofCapitalization
,DialectHandling
,DisplayLength
, andSubstituteHandling
enums inICU4N.Globalization
to match ICU4J numeric values.
New Features
1.ICU4N.Impl.PatternProps
: Added WhiteSpace
static field with the same values that are matched with PatternProps.IsWhiteSpace()
for use in Trim()
method overloads.
8. Added new FormatNumberRuleBased
static class to act as the new API for the ICU4J RuleBasedNumberFormat
functionality. This API consists of extension methods for the numeric data types:
- System.Byte
- System.Int16
- System.Int32
- System.Int64
- System.Int128
- System.Numerics.BigInteger
- System.SByte
- System.IntPtr
- System.UInt16
- System.UInt32
- System.UInt64
- System.UInt128
- System.Half
- System.Single
- System.Double
- System.Decimal
ICU4N.Globalization
: AddedNumberFormatRules
class to serve as the rules engine for the Rule-based Number Format functionality. This class is immutable and thread safe. Optimized Rule-based Number Format rule description string parsing to eliminate unnecessary substring allocations.ICU4N.Text
(SplitTokenizerEnumerator
+MultiDelimiterSplitTokenizerEnumerator
): Added features to control delimiter length to exclude from the token and trim behavior for start/end/both (or specify notrimChars
for no trimming)ICU4N.Globalization
: AddedUNumberFormatInfo
class to cover the .NETNumberFormatInfo
API. This class can be instantiated and used in the same way as the .NET API.ICU4N.Globalization.UNumberFormatInfo
: AddedSpellOut
,Ordinal
,Duration
, andNumberingSystem
properties to expose the rules engines andDefaultRuleSetName
andRuleSetNames
properties publicly. These can be used to deterimine theruleSetName
to pass to theFormatNumberRuleBased
APIs.ICU4N.Globalization.UNumberFormatInfo
: AddedCapitalization
property (DisplayContext
enum in ICU4J).ICU4N
: AddedIcuNumber
internal class to serve as the business logic layer for formatting and parsing. Added formatters for long and double to output native digits + tests to confirm that they are the same as theDecimalFormat
instance that backsRuleBasedNumberFormat
. Also addedFormatPlural()
method + tests andFormatXXXRuleBased()
overloads to prepare the parameters for the call into the rules engine (NumberFormatRules
) that is passed.ICU4N.Text.ValueStringBuilder
: AddedInsert()
overload to handleReadOnlySpan<char>
- Added target for .NET 7.0. Fixed conflicts due to the new
AsReadOnly()
extension methods and build errors due the unsafe logic inPluralRules
.
Improvements
- PERFORMANCE:
ICU4N.Globalization.UCultureInfo.Name
: Cache the name locally so it doesn't have to be parsed on every request. ICU4N.Globalization.UCultureInfo::Canonicalize()
: Added null guard clauseICU4N.Impl.PluralRulesLoader
+ICU4N.Text.PluralRules
: AddedGetInstance()
overload that accepts the culture name as a string, for use by internalUCultureData
class.ICU4N.Globalization.UNumberFormatInfoTest
: Added tests to verify all cultures load decimal format settings correctly (we still have some way to go for currency data)ICU4N.Globalization.NumberPresentationExtensions
: AddedIsDefined()
method so we can quickly check for valid values in guard clauses.ICU4N.Numerics.DecimalQuantity_AbstractBCD
: Optimized number parsing usingReadOnlySpan<char>
where appropriate.- Changed the name of
FEATURE_READONLYDICTIONARY
toFEATURE_IREADONLYCOLLECTIONS
to includeIReadOnlyList<T>
. ICU4N.Globalization.NumberPresentationExtensions
: Added an internal extension method to quickly lookup theNumberingSystemRules
instance for the currentUNumberFormatInfo
.ICU4N.Globalization.UCultureInfo
: AddedReadOnly()
andClone()
implementations and added API documentation forNumberFormat
,IsReadOnly
,ReadOnly()
andClone()
members.ICU4N.Impl.ICUResourceBundle.WholeBundle
: Lazy-load theUCultureInfo
instance so we don't fill up theUCultureData
cache with all cultures and non-culture resource names.
Bug Fixes
ICU4N.Util.ResourceBundle::SetRootType()
: Fixed fallthrough to default forMissing
case