Skip to content

Match String case folding in TextStringBuilder.equalsIgnoreCase#762

Merged
garydgregory merged 1 commit into
apache:masterfrom
alhudz:textstringbuilder-equalsignorecase-fold
Jul 11, 2026
Merged

Match String case folding in TextStringBuilder.equalsIgnoreCase#762
garydgregory merged 1 commit into
apache:masterfrom
alhudz:textstringbuilder-equalsignorecase-fold

Conversation

@alhudz

@alhudz alhudz commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Ports apache/commons-lang#1745 to TextStringBuilder, as requested there.

Repro: new TextStringBuilder("K").equalsIgnoreCase(new TextStringBuilder("K")) (KELVIN SIGN U+212A vs K) returns false, and so does the å/ANGSTROM pair new TextStringBuilder("å").equalsIgnoreCase(new TextStringBuilder("Å")). String.equalsIgnoreCase returns true for both.

Cause: the per-character loop only rules a differing pair equal when Character.toUpperCase(c1) == Character.toUpperCase(c2). Characters that fold together only through their lower-case mapping (U+212A -> k, U+212B -> å) fail that test, so the whole compare reports not-equal.

Fix: also accept the pair when Character.toLowerCase of the upper-cased chars agrees, the same fold String#regionMatches uses. Regression assertions added to TextStringBuilderTest#testEqualsIgnoreCase fail at the Kelvin pair without the main change and pass with it; all 124 tests in the class pass, and the default mvn build is green.


  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory garydgregory merged commit ddaad17 into apache:master Jul 11, 2026
10 of 17 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.

2 participants