do_uconvert(3alleg4)
β¨ do_uconvert β¨
okay bestie, welcome to the Allegro manual π this one's from the Allegro game programming library and it's literally about converting strings between encodings. so niche, so useful, we love her π«Ά
πΈ NAME πΈ
do_uconvert β converts a string to another encoding format π
(Allegro game programming library)
π¦ SYNOPSIS π¦
#include <allegro.h>
void do_uconvert(const char *s, int type, char *buf, int newtype, int
size);
π DESCRIPTION π
okay so here's the vibe: this function takes the string s and converts it from type to newtype, and it drops the result into the output buffer buf β storing at most size bytes in there. no cap. π
and here's the cute part: the type parameters can use the value U_CURRENT as a lil shortcut that means "the currently selected encoding format" β¨ iykyk. like, instead of figuring out what you're currently working with, you just say U_CURRENT and she gets it.
example time, because we're visual learners:
char temp_string[256];
do_uconvert(input_string, U_CURRENT, temp_string, U_ASCII, 256);
π¨ GIRL. LISTEN. even for empty strings β even for EMPTY ones β your destination string still has to have at least enough bytes to store the terminating null character of the string, and your size parameter must reflect that. it's not optional, it's not a suggestion, it's the rules π
and if you don't do it? oh honey π two possibilities and both are bad:
- the debug version of Allegro will abort at an assertion
- the release version of Allegro will overrun the destination buffer
so likeβ¦ give her the bytes she's asking for. protect your buffer. protect yourself. π
π SEE ALSO π
uconvert(3alleg4) β the sibling, go say hi π
alright that's the whole page, bestie, you're officially fluent in do_uconvert π
this was brought to you by Allegro version 4.4.3 π mwah, go convert something pretty β¨π
π¦ 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