RFR: 8372353: API to compute the byte length of a String encoded in a given Charset [v11]

Alan Bateman alanb at openjdk.org
Sun Jan 18 09:09:52 UTC 2026


On Sun, 18 Jan 2026 08:13:40 GMT, Chen Liang <liach at openjdk.org> wrote:

> Question: Have you considered the handling of replacement characters? They currently are counted into the returned length, but I wonder whether users actually want to print those characters as-is.

That is a good point. As `getBytes(Charset)` is specified to replace malformed-input and unmappable-character sequences, and the proposed method is specified to return the equivalent of `getBytes(Charset).length` then the returned length has to include them.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28454#issuecomment-3765082490


More information about the core-libs-dev mailing list