Add u32_is_blank() in 'unicode' module

This commit is contained in:
Thomas Jensen 2023-06-12 22:23:47 +02:00
parent 1b71c4fca2
commit 6c40928ed0
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
2 changed files with 26 additions and 0 deletions

View File

@ -77,6 +77,22 @@ int is_empty(const uint32_t *text)
int u32_is_blank(const uint32_t *text)
{
if (is_empty(text)) {
return 1;
}
for (const uint32_t *c = text; *c != char_nul; c++) {
if (!is_blank(*c)) {
return 0;
}
}
return 1;
}
int is_ascii_printable(const ucs4_t c)
{
return c >= 0x20 && c < 0x7f;

View File

@ -80,6 +80,16 @@ void set_char_at(uint32_t *text, const size_t idx, const ucs4_t char_to_set);
int is_empty(const uint32_t *text);
/**
* Determine if a string consists entirely of blanks.
*
* @param text the string to check, NULL/empty strings count as blank
* @return > 0: the string is blank, empty, or NULL;
* == 0: the string contains at least 1 non-blank character
*/
int u32_is_blank(const uint32_t *text);
int is_ascii_printable(const ucs4_t c);