SDL_wcslen(3)
β¨ SDL_wcslen(3) β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's called SDL_wcslen and it's literally so simple you're gonna be obsessed π
πΈ NAME πΈ
SDL_wcslen β this works exactly like wcslen() but it doesn't need access to a C runtime. no runtime, no problem, we're self-sufficient in this house π
π SYNOPSIS π
#include <SDL3/SDL_stdinc.h>
size_t SDL_wcslen(const wchar_t *wstr);
π¦ DESCRIPTION π¦
So what it does is it counts the number of wchar_t values in wstr, excluding the null terminator. that's it. that's the whole job. and it does it gorgeously β¨
Now here's the tea, and it's important tea: just like SDL_strlen only counts bytes and not codepoints in a UTF-8 string, this one counts wchar_t values in a string β even if the string's encoding is of variable width, like UTF-16. so like, don't come in here expecting codepoints, okay? it's counting wchar_t values. periodt.
Also, be aware: wchar_t is different sizes on different platforms β 4 bytes on Linux, 2 on Windows, etc. so yeah, the vibe of a wchar_t is not universal, it's giving platform-dependent π
π FUNCTION PARAMETERS π
wstrβ the null-terminated wide string to read. Must not beNULL. like fr fr, do not passNULL, that's not the move π
π RETURN VALUE π
Returns the length (in wchar_t values, excluding the null terminator) of wstr. that's your number bestie, go off π
π§ THREAD SAFETY π§
It is safe to call this function from any thread. every thread, all at once, no drama, no notes. iconic behaviour honestly π«Ά
β AVAILABILITY β
This function is available since SDL 3.2.0. if you're on something older... bestie, upgrade π
π₯ SEE ALSO π₯
go read those too, iykyk π
and that's the whole page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, dated with all the love of SDL_wcslen(3) β mwah, take care of your wide strings 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