al_ustr_remove_chr(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_ustr_remove_chr β€” Allegro 5 API πŸ’–

okay bestie, listen up, because this little function from the Allegro 5 API (that's the manual we're in, al_ustr_remove_chr(3alleg5), section 3, the string girlies' section πŸ’…) is genuinely so useful and so underrated.


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

bool al_ustr_remove_chr(ALLEGRO_USTR *us, int pos)

πŸ¦‹ DESCRIPTION πŸ¦‹

Not me about to explain the most iconic little delete button ever. πŸŽ€

So al_ustr_remove_chr removes the code point beginning at byte offset pos. That's it, that's the whole job, and she does it flawlessly. Slay.

It returns true on success. Periodt. πŸ’–

But here's the part you need to hear, no cap: if pos is out of range, or if pos is not the beginning of a valid code point, it returns false and leaves the string unmodified. Like, untouched. Zero damage. The string said "not today" and honestly? Respect. πŸ™ˆ

bestie, this is the vibe check that matters: pos is a byte offset, not a code-point count. Those are NOT the same thing and mixing them up is how you end up with broken strings and a crying session. 😭

So how do you get the right value? Use al_ustr_offset(3alleg5) to find the byte offset for a code-points offset. That's literally its whole purpose, go say hi to her. 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

  • al_ustr_remove_range(3alleg5) β€” for when you wanna delete a whole range and not just one little code point. main character energy, but make it plural. 🌈

and that's the tea, fr fr ⭐

signing off from the Allegro reference manual, al_ustr_remove_chr(3alleg5), Allegro 5, section 3 β€” mwah, go remove some code points responsibly, ily πŸ’œβœ¨

πŸ“¦ where this page comes from