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 π
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms