RFR 8251989: Hex encoder and decoder utility
Roger.Riggs at oracle.com
Thu Aug 20 20:40:57 UTC 2020
The idea was to keep all the Hex functions together.
Its a bit of a mismatch with StringBuilder; StringBuilder doesn't deal
with arrays and is pretty bulky as it is.
And StringBuilder doesn't have a corresponding parse companion; the
string to byte array functions are needed to.
True, the prefix and suffix are conveniences and could be removed. By
knowing it them as part of the encode operation it is possible to
allocate the buffer exactly.
On 8/20/20 3:02 PM, Weijun Wang wrote:
> How about StringBuilder::appendHex instead of Encoder::encode(SB, byte)? Then we don’t need to break the chain when appending many different things to a StringBuilder.
> Also, are prefix and suffix really useful? One can easily add them.
>> On Aug 19, 2020, at 5:14 PM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
>> Please review a java.util.Hex API to encode and decode hexadecimal strings to and from byte arrays.
>> Within the JDK and JDK tests there are multiple implementations to encode and decode
>> hexadecimal strings to byte arrays. Hex encoders and decoders support
>> upper or lower case hexadecimal characters, delimiters, prefix, and suffix.
>> The API is modeled after the java.util.Base64 API providing static factories,
>> immutable threadsafe instances with methods to encode to and decode from
>> string and StringBuilder.
>> Webrev for Hex encoder and decoder:
>> Webrev for applying to java.security:
>> Issue for API and a few uses:
>> Issue for Use in java.security and tests:
More information about the core-libs-dev