uconvert_size(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ uconvert_size(3) ✨

okay bestie, welcome to the Allegro manual β€” this one's uconvert_size, and it's literally the girl who tells you how much room your string is gonna need before you convert it. no cap. πŸŽ€


🌸 NAME 🌸

uconvert_size β€” number of bytes needed to store a string after conversion. it's from the Allegro game programming library, iykyk πŸ’œ


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int uconvert_size(const char *s, int type, int newtype);

πŸ’… DESCRIPTION πŸ’…

so here's the vibe: uconvert_size figures out how many bytes you're gonna need to store the string s after it gets converted from type to newtype. and yes, that count includes the mandatory zero terminator of the string β€” she's thorough, she's not gonna let you forget the null. periodt. πŸ’–

also!! you can use U_CURRENT for either type or newtype and it's a lil shortcut that means "whatever text encoding format is currently selected". iconic behavior honestly. ✨

example time, bestie:

length = uconvert_size(old_string, U_CURRENT, U_UNICODE);
new_string = malloc(length);
ustrcpy(new_string, old_string);

see how she's just doing her lil thing, sizing it up so malloc knows what's up? 🫢


🌈 RETURN VALUE 🌈

returns the number of bytes required to store the string after conversion. that's it, that's the tea. πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘


no guessing, no drama β€” just bytes. go forth and convert, queen πŸ’…

Allegro version 4.4.3 β€” mwah, that's the whole page, uconvert_size(3) and all, dated with the version like a lil time capsule πŸŽ€βœ¨ byeee πŸ¦‹

πŸ“¦ where this page comes from