4 Commits

Author SHA1 Message Date
Tina Liu
e9d59b6065
Fix parsing foreign currency strings (#1074)
* Fix parsing foreign currency strings

Currently parsing a currency string would fail if the currency code does not match `FormatStyle`'s locale region. For example,

```swift
let style = Decimal.FormatStyle.Currency(code: "GBP", locale: .init(identifier: "en_US")).presentation(.isoCode)
```

This formats 3.14 into "GBP\u{0xa0}3.14", but parsing such string fails.

Fix this by always set the ICU formatter's currency code.

Resolves rdar://138179737

* Update the test to throw properly instead of force unwrap

* Remove another force try

* Remove the stored `numberFormatType` and `locale` inside `IntegerParseStrategy` and `FloatingPointParseStrategy`

These properties are redundant as the information is already available through the public variable `formatStyle`.

* Address feedback

* Fix a typo
2025-01-16 08:41:59 -08:00
jacoblukas
787b17380e
Add support for notation to currency format styles (#449) 2024-04-02 16:17:50 -07:00
Joey
32bf8bc848
Documentation - Consistency Fixes (#187)
* Documentation for attributed string's number formatting.

* Documentation - Typos & Consistency Fixes
2023-06-29 10:55:29 -07:00
Charles Hu
2095f3cf69 rdar://107533913 (Move FormatStyles to FoundationPreview) 2023-04-10 17:18:23 -07:00