SDL_utf8strlen(3)
β¨ SDL_utf8strlen β¨
okay bestie, so this one's from the SDL3 functions corner of the SDL3 man pages, and it's literally just: how many characters are in this string, not how many bytes. codepoint counting, no cap. π
πΈ NAME πΈ
SDL_utf8strlen β count the number of codepoints in a UTF-8 string.
π SYNOPSIS π
#include <SDL3/SDL_stdinc.h>
size_t SDL_utf8strlen(const char *str);
π¦ DESCRIPTION π¦
So here's the tea: it counts the _codepoints_, not the _bytes_, in str, and it does not count the null terminator. periodt.
If you actually want the byte count instead, girl, go use SDL_strlen(). different function, different vibe.
And because this one is doing real Unicode work, it expects your strings to be well-formed UTF-8 β not just a null-terminated pile of random bytes. Any bytes that aren't valid UTF-8 get treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), so heads up: a malformed or incomplete UTF-8 sequence might bump your count up by several replacement characters. like, surprise! π it's giving "one broken char, five codepoints."
π FUNCTION PARAMETERS π
strβ the null-terminated UTF-8 string to read. Must not beNULL. do not pass NULL, bestie, i'm begging. π
β RETURN VALUE β
Returns the length (in codepoints, excluding the null terminator) of src. yep, that's what it says β src. we love a lil naming moment. π«Ά
π THREAD SAFETY π
It is safe to call this function from any thread. go off, multithreaded queen. π
π§ AVAILABILITY π§
This function is available since SDL 3.2.0.
π SEE ALSO π
and that's the whole page, no crumbs left π β brought to you by Simple Directmedia Layer, SDL 3.4.18, and this lil SDL_utf8strlen(3) moment. mwah, go count some codepoints. β¨
π¦ 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