### CI Link

https://gradle-enterprise.elastic.co/s/323cgxy7itfky

### Repro line

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.elasticsearch.common.StringsTests.testDeleteAny" -Dtests.seed=8A64C9DD086550D3 -Dtests.locale=it -Dtests.timezone=Asia/Baghdad -Druntime.java=17	

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.timeZoneId=Europe/Rome&tests.container=org.elasticsearch.common.StringsTests&tests.test=testDeleteAny

### Failure excerpt

```
java.lang.AssertionError: |  
  | Expected: "짞ĐGⰣ*ﮢ" |  
  | but: was "짞ĐGⰣﮢ"
```
server/src/test/java/org/elasticsearch/common/StringsTests.java
assertEquals("foo", cleanTruncate("foo", 3));
        
        assertEquals("foo", cleanTruncate("foo\uD83D\uDEAB", 4));
        
        assertEquals("foo\uD83D\uDEAB", cleanTruncate("foo\uD83D\uDEAB", 5));
        /*
         * Doesn't take care around combining marks. This example has its
         * meaning changed because that last codepoint is supposed to combine
         * backwards into the find "o" and be represented as the "o" with a
         * circle around it with a slash through it. As in "no 'o's allowed
         * here.
         */
        assertEquals("o", cleanTruncate("o\uD83D\uDEAB", 1));
        assertEquals("", cleanTruncate("foo", 0));
    }
    public void testTrimLeadingCharacter() {
        assertThat(trimLeadingCharacter("abcdef", 'g'), equalTo("abcdef"));
        assertThat(trimLeadingCharacter("aaabcdef", 'a'), equalTo("bcdef"));
    }
    public void testToStringToXContent() {
        final ToXContent toXContent;
        final boolean error;
        if (randomBoolean()) {
            if (randomBoolean()) {
                error = false;
                toXContent = (builder, params) -> builder.field("ok", "here").field("catastrophe", "");
            } else {
                error = true;
                toXContent = (builder, params) -> builder.startObject().field("ok", "here").field("catastrophe", "").endObject();
            }