Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Fix ICU 72+ whitespace handling in DateTimeToLocalizedStringTransformer#63113

Merged
nicolas-grekas merged 1 commit into
symfony:6.4from
roukmoute:fix/icu72-whitespace-normalization
Jan 20, 2026
Merged

[Form] Fix ICU 72+ whitespace handling in DateTimeToLocalizedStringTransformer#63113
nicolas-grekas merged 1 commit into
symfony:6.4from
roukmoute:fix/icu72-whitespace-normalization

Conversation

@roukmoute
Copy link
Copy Markdown
Contributor

@roukmoute roukmoute commented Jan 18, 2026

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #60178
License MIT

Summary

ICU 72+ uses Unicode whitespace characters (such as U+202F narrow no-break space) in formatted date strings instead of regular ASCII spaces. This caused parsing failures when users typed dates with regular spaces.

This fix:

  • Normalizes transform() output to use regular ASCII spaces for consistent display
  • Makes reverseTransform() accept both regular spaces and ICU 72+ whitespace by trying both formats when parsing fails

How it works

  1. transform(): After formatting with IntlDateFormatter, the output is normalized to replace special Unicode whitespace (U+00A0, U+202F, U+2009) with regular ASCII spaces (U+0020).

  2. reverseTransform(): A new parse() method tries to parse the input as-is first. If parsing fails and the input contains regular spaces, it retries by replacing regular spaces with U+202F (the narrow no-break space used by ICU 72+).

This ensures:

  • Users can type dates with regular spaces
  • Copy-pasted dates from older ICU versions work
  • The displayed output is consistent across ICU versions

Test

The previously skipped test testReverseTransformFromDifferentLocale now works with all ICU versions.

@carsonbot carsonbot added this to the 8.1 milestone Jan 18, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch 2 times, most recently from 6cd3971 to 3500eee Compare January 18, 2026 20:17
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from 3500eee to 44276e7 Compare January 18, 2026 20:43
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 18, 2026
…ansformer

ICU 72+ uses Unicode whitespace characters (such as U+202F narrow no-break space)
in formatted date strings instead of regular ASCII spaces. This caused parsing
failures when users typed dates with regular spaces.

This fix:
- Normalizes transform() output to use regular ASCII spaces for consistent display
- Makes reverseTransform() accept both regular spaces and ICU 72+ whitespace
  by trying both formats when parsing fails

Fix symfony#63113 (review)
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from 44276e7 to b9f24b7 Compare January 18, 2026 20:43
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 18, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from b9f24b7 to 3fec179 Compare January 18, 2026 20:47
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 18, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from 3fec179 to 7fb73f9 Compare January 18, 2026 20:50
@roukmoute roukmoute requested a review from stof January 18, 2026 21:04
@OskarStark OskarStark changed the title [Form] Fix ICU 72+ whitespace handling in DateTimeToLocalizedStringTransformer [Form] Fix ICU 72+ whitespace handling in DateTimeToLocalizedStringTransformer Jan 19, 2026
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 19, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from 7fb73f9 to 0cd8d72 Compare January 19, 2026 11:08
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 19, 2026
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 19, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from 1fc744f to aee1caf Compare January 19, 2026 11:16
roukmoute added a commit to roukmoute/symfony that referenced this pull request Jan 19, 2026
@roukmoute roukmoute force-pushed the fix/icu72-whitespace-normalization branch from aee1caf to 1cfc076 Compare January 19, 2026 11:22
@nicolas-grekas nicolas-grekas modified the milestones: 8.1, 6.4 Jan 20, 2026
@nicolas-grekas nicolas-grekas changed the base branch from 8.1 to 6.4 January 20, 2026 09:01
@nicolas-grekas nicolas-grekas force-pushed the fix/icu72-whitespace-normalization branch from 1cfc076 to 2c1fae0 Compare January 20, 2026 09:01
Copy link
Copy Markdown
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased for 6.4 since that's the oldest maintained version affected

@nicolas-grekas
Copy link
Copy Markdown
Member

Thank you @roukmoute.

@nicolas-grekas nicolas-grekas merged commit ffff4b0 into symfony:6.4 Jan 20, 2026
9 of 12 checks passed
@roukmoute roukmoute deleted the fix/icu72-whitespace-normalization branch January 20, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Form] compatibility with ICU > 7.1 in DateTimeToLocalizedStringTransformer

5 participants