From c60e8f956419a473046d6202abd11d657d7c34bc Mon Sep 17 00:00:00 2001 From: antifallobst Date: Fri, 19 May 2023 01:50:55 +0200 Subject: [PATCH] feature (utils): implemented function to check if a char is a special character --- inc/utils/string.h | 1 + src/utils/string.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/inc/utils/string.h b/inc/utils/string.h index bddc01a..2405c8d 100644 --- a/inc/utils/string.h +++ b/inc/utils/string.h @@ -52,6 +52,7 @@ void string_bool_to_alpha (string_t string, bool value); bool string_is_char_text (char chr); bool string_is_char_number (char chr); +bool string_is_char_special (char chr); bool string_is_char_alpha (char chr); bool string_is_char_uppercase (char chr); bool string_is_char_lowercase (char chr); diff --git a/src/utils/string.c b/src/utils/string.c index 30e1c62..6936356 100644 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -433,6 +433,16 @@ bool string_is_char_number(char chr) { return false; } +bool string_is_char_special(char chr) { + if ((chr >= '!' && chr <= '/') || + (chr >= ':' && chr <= '@') || + (chr >= '^' && chr <= '`') || + (chr >= '{' && chr <= '~')) { + return true; + } + return false; +} + bool string_is_char_alpha(char chr) { if (string_is_char_uppercase(chr) || string_is_char_lowercase(chr) || string_is_char_number(chr)) { return true;