I need to create a Collator which corresponds to https://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive/ i.e. it ignores the case sensitivity of ASCII A-Z
and a-z
characters when making comparisons.
I have attempted this with the following ICU4j RuleBasedCollator
:
final RuleBasedCollator collator =
new RuleBasedCollator("&a=A, b=B, c=C, d=D, e=E, f=F, g=G, h=H, "
+ "i=I, j=J, k=K, l=L, m=M, n=N, o=O, p=P, q=Q, r=R, s=S, t=T, "
+ "u=U, v=V, u=U, v=V, w=W, x=X, y=Y, z=Z").freeze();
However, the following comparison seems to fail, where I would expect it to succeed (i.e. return true
):
final SearchIterator searchIterator = new StringSearch(
"pu", new StringCharacterIterator("iNPut"), collator);
return searchIterator.first() >= 0;
What am I missing in my rules?