From 0aa55e224cab2e2ea3f25004a4f479e296714950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 20 Jun 2023 23:01:55 +0200 Subject: [PATCH] Add `str_isallnum_hex` To check if string contains only `[0-9a-zA-Z]`. --- src/base/system.cpp | 11 +++++++++++ src/base/system.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/base/system.cpp b/src/base/system.cpp index d08cb7d02..406c8e36f 100644 --- a/src/base/system.cpp +++ b/src/base/system.cpp @@ -3430,6 +3430,17 @@ int str_isallnum(const char *str) return 1; } +int str_isallnum_hex(const char *str) +{ + while(*str) + { + if(!(*str >= '0' && *str <= '9') && !(*str >= 'a' && *str <= 'f') && !(*str >= 'A' && *str <= 'F')) + return 0; + str++; + } + return 1; +} + int str_toint(const char *str) { return str_toint_base(str, 10); diff --git a/src/base/system.h b/src/base/system.h index 74ed2fe63..6535d66dd 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -2186,7 +2186,11 @@ float str_tofloat(const char *str); int str_isspace(char c); char str_uppercase(char c); + int str_isallnum(const char *str); + +int str_isallnum_hex(const char *str); + unsigned str_quickhash(const char *str); enum