SDL_iconv_wchar_utf8(3)

πŸ’– SDL_iconv_wchar_utf8 πŸ’–

okay bestie so we're in the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_iconv_wchar_utf8 β€” she converts a wchar_t string to UTF-8 and she does it in literally one line. iconic behavior fr fr πŸ¦‹


✨ NAME ✨

SDL_iconv_wchar_utf8 β€” turn a wchar_t string into UTF-8, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_iconv_wchar_utf8(S)     SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t))

like... that's it. that's the whole thing. she's a macro, she's gorgeous, she's efficient 😌✨


πŸŽ€ DESCRIPTION πŸŽ€

So this is a helper macro, and her whole personality is being clearer than calling SDL_iconv_string directly. Which like, valid. Sometimes you just want the vibe without spelling out all the args, yk?

⚠️ BUT LISTEN. She double-evaluates her parameter. So do NOT pass in an expression with side-effects. Not even a little. That's the one rule. Respect it or suffer the consequences bestie πŸ˜­πŸ’€

🧚 MACRO PARAMETERS 🧚

  • S β€” the string to convert. that's the girl. that's the one you're converting 🫢

πŸ‘‘ RETURN VALUE πŸ‘‘

She returns a new string, converted to the new encoding. ✨

Or NULL on error. πŸ˜” which... we don't talk about.


πŸ”₯ THREAD SAFETY πŸ”₯

Safe to call from any thread. periodt. she's chill like that πŸ’œ


🌈 AVAILABILITY 🌈

This macro has been available since SDL 3.2.0. so if you're on something older, she's not there yet, sorry babe πŸ™ˆ


okay that's the whole page, you ate that, go convert some strings πŸ’–βœ¨

β€” with love from the Simple Directmedia Layer girlies, SDL 3.4.18, and this lil SDL_iconv_wchar_utf8(3) page πŸŽ€ bye bestie!! πŸŒΈπŸ¦‹πŸ’…

πŸ“¦ where this page comes from