Open gissuebot opened 9 years ago
Original comment posted by kevinb@google.com on 2012-06-19 at 05:54 PM
(No comment entered for this change.)
Status: Acknowledged
Labels: Type-Addition
, Package-Base
Original comment posted by wasserman.louis on 2012-06-22 at 02:21 PM
Generalization: CharMatcher.digits(int radix), with implementation
public boolean matches(char c) { return Character.digit(c, radix) != -1; }
Original comment posted by kevinb@google.com on 2012-06-22 at 06:16 PM
(No comment entered for this change.)
Status: Research
Original comment posted by kostmo on 2013-12-25 at 01:12 PM
Two solutions I came up with, neither very nice: CharMatcher.anyOf("0123456789abcdefABCDEF") or CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'f')).or(CharMatcher.inRange('A', 'F'))
Original comment posted by cpovirk@google.com on 2014-01-08 at 04:04 PM
The main question I have for this is "What will the code do differently if it knows the input is only hex digits?" In most cases, I would still expect for parsing to be able to fail: parseInt could be given a value that's out of range or empty. BaseEncoding could be given uppercase/lowercase when it expects the reverse, or it could be given an odd number of characters.
Another possibility is the opposite problem: parseInt also accepts negative signs (though probably some users want an unsigned parse method, anyway). BaseEncoding also accepts separators. CharMatcher.HEXADECIMAL would reject both.
Original issue created by em...@soldal.org on 2012-06-14 at 02:14 PM
Hexadecimal checking seems to be something that I do rather often, Could we add this to CharMatcher as a standard matcher?