RFR: 8251989: Hex formatting and parsing utility [v10]
Naoto Sato
naoto at openjdk.java.net
Fri Nov 27 22:43:01 UTC 2020
On Fri, 27 Nov 2020 16:57:07 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/HexFormat.java line 853:
>>
>>> 851: */
>>> 852: public int fromHexDigit(int ch) {
>>> 853: int value = Character.digit(ch, 16);
>>
>> Do we need to limit parsing the hex digit for only [0-9a-fA-F]? This would return `0` for other digits, say `fullwidth digit zero` (U+FF10)
>
> The normal and conventional characters for hex encoding are limited to the ASCII/Latin1 range.
> I don't know of any use case that would take advantage of non-ASCII characters.
My point is that probably we should define `hexadecimal string` more clearly. In the class description, that exclusively means [0-9a-fA-F] in the context of formatting, but in the parsing, it allows non-ASCII digits. e.g.,
HexFormat.of().parseHex("\uff10\uff11")
Succeeds. I would like consistency here.
-------------
PR: https://git.openjdk.java.net/jdk/pull/482
More information about the core-libs-dev
mailing list