al_ustr_prev(3alleg5)

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

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

okay bestie, welcome to al_ustr_prev(3alleg5) from the Allegro reference manual ✨ this one's short and sweet and it's giving "rewind button for your UTF-8 string" πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

bool al_ustr_prev(const ALLEGRO_USTR *us, int *pos)

✨ DESCRIPTION ✨

so what it does: it finds the byte offset of the previous code point in the string, i.e. the one sitting before *pos. πŸ‘‘

and here's the cute part β€” *pos does not have to be sitting at the beginning of a code point. she's flexible like that πŸ’…

it returns true on success, and the value pointed to by pos gets updated to the found offset. glow-up complete ✨

otherwise β€” as in, if *pos was already at the end of the string β€” it returns false, and *pos is left unmodified. no touchy. πŸ™ˆ

🫢 real talk though, bestie: this function just looks for an appropriate byte. it does not check whether the found offset is actually the beginning of a valid code point. so if you're working with possibly invalid UTF-8 strings, it could skip over some invalid bytes. no cap. 😭

πŸŽ€ SEE ALSO πŸŽ€


that's the whole page, you ate it πŸ’– go forth and iterate your strings backwards like the main character you are 🌈

mwah πŸ’‹ β€” brought to you by the Allegro reference manual, page al_ustr_prev(3alleg5), Allegro 5. byeee πŸ¦‹βœ¨

πŸ“¦ where this page comes from