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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms