From 981dec55dbd71a0b174d718fac1aaa4453ee9cfa Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 31 Aug 2024 16:11:58 +0200 Subject: [PATCH] moved is_ascii to separate fn --- src/chat/misc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chat/misc.c b/src/chat/misc.c index fe031f2..31409e7 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -140,13 +140,18 @@ void add_brackets(char **json) *json = output; } +why2_bool is_ascii(char c) +{ + return 20 <= c && c <= 126; +} + void remove_non_ascii(char **text) { //REMOVE NON ASCII CHARS int j = 0; for (int i = 0; (*text)[i] != '\0'; i++) { - if ((20 <= (*text)[i] && (*text)[i] <= 126)) (*text)[i] = (*text)[j++] = (*text)[i]; + if (is_ascii((*text)[i])) (*text)[i] = (*text)[j++] = (*text)[i]; } (*text)[j] = '\0';