Skip to content

Match String case folding in StrBuilder.equalsIgnoreCase#1745

Open
alhudz wants to merge 1 commit into
apache:masterfrom
alhudz:strbuilder-equalsignorecase-fold
Open

Match String case folding in StrBuilder.equalsIgnoreCase#1745
alhudz wants to merge 1 commit into
apache:masterfrom
alhudz:strbuilder-equalsignorecase-fold

Conversation

@alhudz

@alhudz alhudz commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Repro: new StrBuilder("K").equalsIgnoreCase(new StrBuilder("K")) (KELVIN SIGN vs K) returns false, and so does the å/ANGSTROM pair new StrBuilder("å").equalsIgnoreCase(new StrBuilder("Å")). 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+212Ak, 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 and this library's own CharSequenceUtils.equalsIgnoreCase already use. The case-sensitive equals sibling is untouched.

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