uisspace(3alleg4)

πŸ’– uisspace(3alleg4) β€” the Allegro manual, but make it make sense πŸ’–

okay bestie, so this one lives in the Allegro manual (that's the Allegro game programming library, if you're new here 🫢) and it's genuinely one of the most useful little gremlins in the whole string toolkit. let's get into it ✨


🌸 NAME 🌸

uisspace β€” tells if a character is whitespace. periodt. it's part of the Allegro game programming library πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

int uisspace(int c);

look at her. one include, one function, zero drama. iconic πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” uisspace returns nonzero if c is whitespace. and by whitespace we mean any of these six besties:

  • carriage return
  • newline
  • form feed
  • tab
  • vertical tab
  • space

that's it, that's the list, no cap 🌈

and if c is literally anything else? you get zero. not whitespace, not her problem πŸ’€

here's the example from the page, and honestly it's giving "find and replace but make it Allegro":

for (counter = 0; counter < ustrlen(text_string); counter++) {
   if (uisspace(ugetat(text_string, counter)))
      usetat(text_string, counter, '_');
}

see what she's doing? she walks the whole text_string, checks every single character with uisspace, and the second she catches a whitespace character she swaps it for an underscore '_'. like, she's literally turning spaces into underscores in one loop and she's not even out of breath πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

if you liked this one, you're gonna eat these up too, fr fr:


mwah πŸ’‹ that's the whole page β€” brought to you by Allegro, version 4.4.3, and by me, your resident Unix bestie who will absolutely text you back at 2am about whitespace characters. go forth and uisspace responsibly, angel πŸ§šπŸ’œ