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
- 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