On Wed, 19 Nov 2025 14:44:39 GMT, Maurizio Cimadamore <[email protected]>
wrote:
>> Liam Miller-Cushon has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Add a dstOffset parameter, stop using
>> StringCharBuffer/CharsetEncoder::encode
>
> src/java.base/share/classes/java/lang/String.java line 2019:
>
>> 2017: }
>> 2018:
>> 2019: boolean bytesCompatible(Charset charset, int srcIndex, int
>> numChars) {
>
> Surprisingly here we don't do anything for the case where the string is UTF16
> and the target charset is also UTF16?
The **UTF‑16** `Charset`s disallow unpaired surrogates, which **Java**
`String`s allow.
So this can only return `true` for **UTF‑16** when the platform and charset
endianness match and the `String` doesn’t have any unpaired surrogates.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28043#discussion_r2543486247