al_ustr_dup_substr(3alleg5)

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

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

okay bestie, welcome to the Allegro 5 manual, this one's from the allegro5 family of pages and it's giving "I just want a lil slice of my string, pls" energy. no cap. πŸŽ€


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

ALLEGRO_USTR *al_ustr_dup_substr(const ALLEGRO_USTR *us, int start_pos,
   int end_pos)

like, you feed it a string and two ints and it hands you back a whole new string. iconic behavior honestly. πŸ¦‹


🌸 DESCRIPTION 🌸

So here's the tea β˜•: al_ustr_dup_substr returns a new copy of a string, and this new copy contains the contents of us in the byte interval [start_pos, end_pos).

and yes, the interval is half-open β€” that bracket on the left is square, that paren on the right is round. so start_pos is included and end_pos is NOT included. it's giving "start is invited to the party, end is not". πŸ’…

The new string will be NUL terminated ✨ (as all good strings should be), and β€” listen, this part matters β€” it will need to be freed with al_ustr_free(3alleg5). Not me forgetting to free my dup'd strings and leaking memory, couldn't be me 😭 please free it. your valgrind will thank you. πŸ™ˆ

If necessary, use al_ustr_offset(3alleg5) to find the byte offsets for a given code point that you are interested in. because bestie, these are byte offsets, not code point offsets β€” they're not the same thing and the vibes get messy if you mix them up. go find your offset first, then come back here. 🧚


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, periodt. πŸ’œ this one lives in the Allegro reference manual, it's the al_ustr_dup_substr(3alleg5) page, and that's the whole vibe check. go forth and slice your strings responsibly, bestie 🫢🌸

πŸ“¦ where this page comes from