moved is_ascii to separate fn

This commit is contained in:
Václav Šmejkal 2024-08-31 16:11:58 +02:00
parent f7982d4d4a
commit 981dec55db
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -140,13 +140,18 @@ void add_brackets(char **json)
*json = output; *json = output;
} }
why2_bool is_ascii(char c)
{
return 20 <= c && c <= 126;
}
void remove_non_ascii(char **text) void remove_non_ascii(char **text)
{ {
//REMOVE NON ASCII CHARS //REMOVE NON ASCII CHARS
int j = 0; int j = 0;
for (int i = 0; (*text)[i] != '\0'; i++) 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'; (*text)[j] = '\0';