Skip to content

ext/intl: Use byte offsets in IntlDateFormatter parsing - #399

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-intl-datefmt-offset-units-l91k-84-work
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-intl-datefmt-offset-units-l91k-84-work

Conversation

@iliaal

@iliaal iliaal commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Translate PHP byte offsets to ICU UTF-16 positions and back for IntlDateFormatter parsing APIs, including calendar errors.

IntlDateFormatter::parse(), localtime() and parseToCalendar() passed the
PHP byte offset to ICU, which expects a UTF-16 code-unit position, and
returned ICU's position unchanged. With multibyte text before the date,
parsing started at the wrong place and the returned offset was too
small. Convert the offset in both directions as phpGH-23094 did for
NumberFormatter, and reject an offset that splits a UTF-8 sequence. A
returned position inside a surrogate pair, which a partially matched
literal can produce, maps to the start of that character.
@iliaal
iliaal force-pushed the fix/aph-intl-datefmt-offset-units-l91k-84-work branch from b5fa330 to dc74a76 Compare October 4, 2026 21:26
@iliaal iliaal changed the title ext/intl: Convert date parse offsets ext/intl: Use byte offsets in IntlDateFormatter parsing Oct 4, 2026
@iliaal

iliaal commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#24126.

@iliaal iliaal closed this Oct 4, 2026
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.

1 participant