account for uppercase hex
This commit is contained in:
parent
db57a7c5e9
commit
390b123fb7
@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
constexpr uint8_t nib_from_hex(char c) {
|
constexpr uint8_t nib_from_hex(char c) {
|
||||||
assert((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'));
|
assert((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
|
||||||
|
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
return static_cast<uint8_t>(c) - '0';
|
return static_cast<uint8_t>(c) - '0';
|
||||||
} else if (c >= 'a' && c <= 'f') {
|
} else if (c >= 'a' && c <= 'f') {
|
||||||
return (static_cast<uint8_t>(c) - 'a') + 10u;
|
return (static_cast<uint8_t>(c) - 'a') + 10u;
|
||||||
|
} else if (c >= 'A' && c <= 'F') {
|
||||||
|
return (static_cast<uint8_t>(c) - 'A') + 10u;
|
||||||
} else {
|
} else {
|
||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user