From cc3e71d8c7e2eb177dfcec95f75640c694fd83c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Apr 2020 12:59:33 +0200 Subject: [PATCH] util/CharUtil: add IsHexDigit() --- src/util/CharUtil.hxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/CharUtil.hxx b/src/util/CharUtil.hxx index 2dc7e34eb..44c3ad1f8 100644 --- a/src/util/CharUtil.hxx +++ b/src/util/CharUtil.hxx @@ -130,4 +130,12 @@ ToLowerASCII(char ch) noexcept : ch; } +constexpr bool +IsHexDigit(char ch) noexcept +{ + return IsDigitASCII(ch) || + (ch >= 'a' && ch <= 'f') || + (ch >= 'A' && ch <= 'F'); +} + #endif