Kristian Rickert created OPENNLP-1985:
-----------------------------------------

             Summary: StringUtil.toUpperCase does not uppercase supplementary 
Unicode letters
                 Key: OPENNLP-1985
                 URL: https://issues.apache.org/jira/browse/OPENNLP-1985
             Project: OpenNLP
          Issue Type: Bug
            Reporter: Kristian Rickert
             Fix For: 2.5.13, 3.0.0


h2. Problem

{{StringUtil.toUpperCase(CharSequence)}} iterates UTF-16 chars and calls
{{Character.toUpperCase(char)}}. Supplementary letters occupy a surrogate pair,
so lowercase letters outside the BMP are returned unchanged.

h2. Reproduction

{code:java}
String input = new String(Character.toChars(0x10428));
String result = StringUtil.toUpperCase(input);
// Expected: U+10400 (DESERET CAPITAL LETTER LONG I)
// Actual:   U+10428 (DESERET SMALL LETTER LONG I)
{code}

The affected implementation is present on both branches checked on 2026-09-19:
* {{opennlp-2.x}} at {{26f394a6ab01bf757334ba88f03bc9e2a42f6c27}}.
* {{main}} at {{f2ab1ccd435c20e910008511a37467131683e9c7}}.

The failure was reproduced against the exact 2.x source. These branch checks
are not a determination of the earliest affected released version.

h2. Proposed fix and validation

Use a code-point cursor and {{Character.toUpperCase(int)}}. Preserve simple
Unicode case mapping without multi-character expansions.

Add regressions for supplementary letters, mixed BMP/supplementary text,
unpaired surrogates and non-String CharSequence inputs. Verify that the source
is not modified and that existing BMP behavior remains correct.

Keep public signatures and null-input exception behavior unchanged. Changes to
lowercase conversion or dependent callers are outside this issue.

Prepare focused fixes for main and opennlp-2.x under this issue.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to