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 be NULL. like fr fr, do not pass NULL, 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