SDL_iconv_utf8_ucs4(3)

πŸ’– SDL_iconv_utf8_ucs4 πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS corner of the manual, and the star of the show is SDL_iconv_utf8_ucs4. Let's get into it ✨


🌸 NAME 🌸

SDL_iconv_utf8_ucs4 β€” convert a UTF-8 string to UCS-4. that's it, that's the whole job πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

#define SDL_iconv_utf8_ucs4(S)      SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1))

πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a helper macro, right? And it might be more clear than calling SDL_iconv_string directly. Might! No promises! It's giving "convenience wrapper" energy and honestly we love that for it 🫢

BUT. And this is a big but, bestie. 🚨 It double-evaluates its parameter, so do not use an expression with side-effects here. Not even a little one. Not even a cute one. That's the whole caveat, and it's a real one β€” the macro literally runs your argument twice, so if your argument does something spicy, it does that spicy thing twice. be so serious about this one 😭


🌈 MACRO PARAMETERS 🌈

  • S β€” the string to convert. just hand it your string, that's it πŸ’–

⭐ RETURN VALUE ⭐

Returns a new string, converted to the new encoding, or NULL on error. So if you get NULL back, something went wrong β€” that's your vibe check failing πŸ™ˆ


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this macro from any thread. go off, queen πŸ‘‘


πŸ‘‘ AVAILABILITY πŸ‘‘

This macro is available since SDL 3.2.0. so if you're on something older... no cap, it's not there πŸ’€


and that's the whole page, bestie!! mwah πŸŽ€ this little gem comes to you from Simple Directmedia Layer, shipped in SDL 3.4.18 β€” the SDL_iconv_utf8_ucs4(3) era, iconic as always. go convert something gorgeous πŸ’œβœ¨

πŸ“¦ where this page comes from