Skip to content

ICU-23645 Fix PAD_AFTER_SUFFIX padding with currency spacing - #4399

Open
sffc wants to merge 1 commit into
unicode-org:mainfrom
sffc:ICU-23645
Open

sffc wants to merge 1 commit into
unicode-org:mainfrom
sffc:ICU-23645

Conversation

@sffc

@sffc sffc commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes ICU-23645.

MutablePatternModifier::apply() in both ICU4C and ICU4J called CurrencySpacingEnabledModifier::applyCurrencySpacing() and discarded its return value. When currency spacing inserted a space on the one-shot (non-compiled) formatting path, Padder::padAndApply() received a length 1 code unit too small and spliced PAD_AFTER_SUFFIX padding before the last digit or inside the currency code on calls 1–2 (e.g., "CHF\u00A0123.4______5", "123,12\u00A0CN______¥"), before switching to the expected position on call 3+ once compiled.

This PR adds the spacing length returned by applyCurrencySpacing() to the return value of MutablePatternModifier::apply() in both ICU4C and ICU4J (matching CurrencySpacingEnabledModifier::apply()), and adds prefix and suffix currency-spacing + PAD_AFTER_SUFFIX regression tests to NumberFormatterApiTest in both languages.

🤖 This pull request was created by an AI agent working with @sffc.

Checklist

  • Required: Issue filed: ICU-23645
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

MutablePatternModifier::apply() in ICU4C and ICU4J discarded the return
value of CurrencySpacingEnabledModifier::applyCurrencySpacing(), causing
returned lengths to be short by the inserted spacing length on the
one-shot formatting path. Downstream callers such as Padder::padAndApply
(PAD_AFTER_SUFFIX) then spliced padding inside the last digit or
currency code until the formatter compiled on call 3.

Add the spacing length returned by applyCurrencySpacing() to the return
value of MutablePatternModifier::apply() in both ICU4C and ICU4J, and
add prefix and suffix currency-spacing + PAD_AFTER_SUFFIX regression
tests to NumberFormatterApiTest.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sffc
sffc marked this pull request as ready for review November 25, 2026 03:23
@sffc

sffc commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

My AI agent noticed this while working on a different bug.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants