SDL_iconv_utf8_locale(3)
π SDL_iconv_utf8_locale(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_iconv_utf8_locale from <SDL3/SDL_stdinc.h>. it's a macro. it's tiny. it's iconic. let's get into it π¦
β¨ NAME β¨
SDL_iconv_utf8_locale β convert a UTF-8 string to the current locale's character encoding. literally that's the whole job description, and she does it flawlessly π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
look at her. one line. no cap. π
π«Ά DESCRIPTION π«Ά
so this is a helper macro, and the whole point of her existence is that she might be more clear than calling SDL_iconv_string directly. like, sometimes you just wanna say "utf8 β locale, go" and not spell out every argument, yk? iykyk.
but β and this is the part where we sit down and have a serious chat β she double-evaluates her parameter. so do not pass in an expression with side-effects here. fr fr. if your argument does something spicy when it runs, it's gonna do that spicy thing twice, and that's a you problem, not a macro problem π
β οΈ reminder: no side-effect expressions in S. she will evaluate it twice and she will not apologise.
π§ MACRO PARAMETERS π§
Sβ the string to convert. that's it, that's the whole parameter list, she's low maintenance π
π RETURN VALUE π
Returns a new string, converted to the new encoding. or NULL on error. so like, check her before you use her, bestie π
π THREAD SAFETY π
It is safe to call this macro from any thread. yes queen, thread-safe, no drama, go off π
β AVAILABILITY β
This macro is available since SDL 3.2.0. so if you're on something older, sorry babe, she hasn't been born yet π₯Ί
and that's the whole page!! every flag, every parameter, every return value, every thread-safety note, all of it, preserved and slaying β¨
this has been brought to you by Simple Directmedia Layer β SDL 3.4.18 β and yeah, the page footer says SDL_iconv_utf8_locale(3) down there too, consider it signed off with a kiss π
mwah π go convert some strings, you've got this π«Ά
π¦ 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