SDL_iconv_utf8_ucs2(3)
π SDL_iconv_utf8_ucs2 π
okay bestie, welcome to the SDL_iconv_utf8_ucs2 page from the SDL3 crew (Simple Directmedia Layer, if we're being formal β¨) β it's a macro, it's cute, it turns your UTF-8 into UCS-2, and it lives in <SDL3/SDL_stdinc.h>. let's get into it π¦
β¨ NAME β¨
SDL_iconv_utf8_ucs2 β converts a UTF-8 string into UCS-2. that's it, that's the whole job, and it slays π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
#define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1))
yes, that's the entire macro, no cap. it's a one-liner and it's iconic for it π
π DESCRIPTION π
so this is a helper macro, and the whole point of it is that it might be more clear than calling SDL_iconv_string directly. like, sometimes you just want the vibe to be readable, yk? π«Ά
but bestie, listen, this is the important part: it double-evaluates its parameter. so do not use an expression with side-effects here. fr fr. if your argument does something spicy every time it's touched, it's gonna do that spicy thing twice, and that is not the moment π
π§ MACRO PARAMETERS π§
Sβ the string to convert. that's the one, the only, the main character of this macro π
π RETURN VALUE π
it returns a new string, converted to the new encoding β or NULL on error. so like, check for NULL, bestie, don't just rawdog it into your code π
π THREAD SAFETY π
it is safe to call this macro from any thread. go wild, go parallel, go off π₯
β AVAILABILITY β
this macro has been available since SDL 3.2.0. so if you're on something older, sorry babe, no macro for you π
and that's the page!! mwah π this was brought to you by Simple Directmedia Layer, SDL 3.4.18 β shoutout to the whole SDL3 era, couldn't have done it without you. go forth and convert your encodings, you absolute legend πβ¨π¦
π¦ 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