SDL_iconv_string(3)
π SDL_iconv_string π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_iconv_string(3) β the helper function that converts a string's encoding in ONE call. no drama, no multi-step ritual, just vibes β¨
πΈ NAME πΈ
SDL_iconv_string β helper function to convert a string's encoding in one call. that's it, that's the whole job, and she does it flawlessly π
π SYNOPSIS π
#include <SDL3/SDL_stdinc.h>
char * SDL_iconv_string(const char *tocode,
const char *fromcode,
const char *inbuf,
size_t inbytesleft);
look at her. four params, one dream. π¦
β¨ DESCRIPTION β¨
This function converts a buffer or string between encodings in one pass. like, one and done, no cap π«Ά
The string does not need to be NULL-terminated β not even a little. this function operates on the number of bytes specified in inbytesleft, whether there's a NULL character lurking somewhere in the buffer or not. so if you've got a NULL in the middle, she does not care, she is reading exactly inbytesleft bytes and that is that π
The returned string is owned by the caller, and should be passed to SDL_free when no longer needed. yes bestie, that means you are responsible for freeing it. don't just leave her hanging in memory forever, that's not the vibe π
π₯ FUNCTION PARAMETERS π₯
tocodeβ the character encoding of the output string. examples are"UTF-8","UCS-4", etc. this is where you're going π«fromcodeβ the character encoding of data ininbuf. this is where you're coming from π¬inbufβ the string to convert to a different encoding.inbytesleftβ the size of the input string _in bytes_. emphasis on BYTES, okay, not characters, not vibes, bytes π
π RETURN VALUE π
Returns a new string, converted to the new encoding, or NULL on error. so if you get NULL back, something went wrong and you should go check yourself before you wreck yourself π
π§ THREAD SAFETY π§
It is safe to call this function from any thread. multi-threaded besties, you are SO covered π
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on anything older, sorry babe, she's not there yet π
π SEE ALSO π
and that's the whole page, bestie!! go forth and convert encodings responsibly π
this has been a Simple Directmedia Layer production, SDL 3.4.18 era, brought to you by the one and only SDL_iconv_string(3) β stan her, free your strings, and hydrate π«Άβ¨
π¦ 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