Skip to content

Fix $substring on strings with non-BMP characters (#123) - #126

Merged
uw4 merged 1 commit into
mainfrom
123-substring-throws-indexoutofboundsexception-on-strings-with-non-bmp-characters-when-length-is-omitted-or-too-large
Nov 4, 2026
Merged

uw4 merged 1 commit into
mainfrom
123-substring-throws-indexoutofboundsexception-on-strings-with-non-bmp-characters-when-length-is-omitted-or-too-large

Conversation

@aeberhart

Copy link
Copy Markdown
Contributor

substr counted length in UTF-16 units instead of code points, and from the start of the string instead of from start. This threw an IndexOutOfBoundsException when length was omitted or too large, and returned wrong or split characters when non-BMP characters came before start. Now length is clamped to the code points remaining after start and converted from there.

substr counted length in UTF-16 units instead of code points, and
from the start of the string instead of from `start`. This threw an
IndexOutOfBoundsException when length was omitted or too large, and
returned wrong or split characters when non-BMP characters came
before `start`. Now length is clamped to the code points remaining
after `start` and converted from there.
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Test Results

1 797 tests  +1   1 794 ✅ +1   8s ⏱️ ±0s
  120 suites ±0       3 💤 ±0 
  120 files   ±0       0 ❌ ±0 

Results for commit d71da7c. ± Comparison against base commit 7dd27a5.

@uw4
uw4 merged commit 6b2f23a into main Nov 4, 2026
2 checks passed
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.

$substring throws IndexOutOfBoundsException on strings with non-BMP characters when length is omitted or too large

2 participants