On Fri, 22 Sep 2023 06:25:39 GMT, Alan Bateman <[email protected]> wrote:

>> Claes Redestad has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   REPLACE, add comment, add tests verifying that surrogate pairs at boundary 
>> works.
>
> src/java.base/share/classes/java/net/URLEncoder.java line 250:
> 
>> 248:         CharsetEncoder ce = charset.newEncoder()
>> 249:                 .onMalformedInput(CodingErrorAction.REPLACE)
>> 250:                 .onUnmappableCharacter(CodingErrorAction.REPLACE);
> 
> @dfuch The explicit use of the REPLACE action makes me wonder if the spec 
> should be clarified at some point as it doesn't seem to be documented.

FWIW this doesn't change behavior of `encode`, since this is what 
`String::getBytes(Charset)` does (and is specified to do):
``` 
     * <p> This method always replaces malformed-input and unmappable-character
     * sequences with this charset's default replacement byte array.

I'd be happy to spell it out in the documentation, just pointing out that it's 
been long-standing behavior.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15865#discussion_r1334037846

Reply via email to