summaryrefslogtreecommitdiffstats
path: root/base/string_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/string_util.h')
-rw-r--r--base/string_util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/string_util.h b/base/string_util.h
index 762779c..97b5100 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -380,6 +380,18 @@ inline bool IsHexDigit(Char c) {
(c >= 'a' && c <= 'f');
}
+template <typename Char>
+inline Char HexDigitToInt(Char c) {
+ DCHECK(IsHexDigit(c));
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ return 0;
+}
+
// Returns true if it's a whitespace character.
inline bool IsWhitespace(wchar_t c) {
return wcschr(kWhitespaceWide, c) != NULL;