diff options
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/string.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index 4dbed0fd2..0aa7771a7 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -491,21 +491,18 @@ std::string WideToUtf8(const std::wstring_view Wstr); inline uint8_t Char2Nibble(char c) { - uint8_t c8 = uint8_t(c - '0'); - - if (c8 < 10) - return c8; - - c8 -= 'A' - '0' - 10; - - if (c8 < 16) - return c8; - - c8 -= 'a' - 'A'; - - if (c8 < 16) - return c8; - + if (c >= '0' && c <= '9') + { + return uint8_t(c - '0'); + } + if (c >= 'a' && c <= 'f') + { + return uint8_t(c - 'a' + 10); + } + if (c >= 'A' && c <= 'F') + { + return uint8_t(c - 'A' + 10); + } return uint8_t(0xff); }; |