uwidth_max(3alleg4)

✨ NAME ✨

okay so bestie, this is uwidth_max from the Allegro game programming library β€” it tells you the max number of bytes a single character can possibly take up πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int uwidth_max(int type);

πŸ’– DESCRIPTION πŸ’–

so this is a low level helper function for when you're out here doing Unicode text data stuff, and it's giving very much "how much room do I need to budget per character" energy πŸŽ€

It returns the largest number of bytes that one character can occupy in the encoding format you hand it. That's it, that's the whole vibe β€” worst case, one character, this many bytes, plan accordingly 🫢

You pass in U_CURRENT when you wanna represent the current format, no cap. Iconic shortcut behavior honestly.

Example, because seeing it is believing:

char *temp_buffer = malloc(256 * uwidth_max(U_UTF8));

not me allocating a buffer that's 256 characters wide in whatever U_UTF8 can throw at me 😭✨


πŸ¦‹ SEE ALSO πŸ¦‹


k bye bestie, go forth and never under-allocate your Unicode buffers again πŸ’–

this has been your girl, signing off from the Allegro manual, version 4.4.3 β€” periodt πŸ’