SDL_wcsncmp(3)
π SDL_wcsncmp π
okay bestie, this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_wcsncmp β she compares two wide strings, but only up to a certain number of wchar_t values. no cap. let's get into it π¦
β¨ NAME β¨
SDL_wcsncmp β compare two wide strings up to a number of wchar_t values.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
π DESCRIPTION π
so here's the vibe: this function only compares wchar_t values. it does not care whether your string is well-formed UTF-16 (or UTF-32, depending on how big wchar_t is on your platform), and it does not care whether you're using valid Unicode values. it is simply not that girl. she's looking at raw numbers, periodt.
now, note this, because it's important π β even though this function is intended to be used with UTF-16 (or UTF-32, depending on your platform's definition of wchar_t), it's comparing raw wchar_t values and not Unicode codepoints. that means maxlen specifies a wchar_t limit! if that limit lands in the middle of a multi-wchar UTF-16 sequence, it will only compare a portion of the final character. π like, imagine getting cut off mid-sentence. that's her. that's the function.
maxlen specifies a maximum number of wchar_t to compare. if the strings match to this number of wide chars β or if both have already matched up to a null-terminator character before reaching this count β they'll be considered equal. slay β¨
π FUNCTION PARAMETERS π
str1β the first string to compare.NULLis not permitted! πstr2β the second string to compare.NULLis not permitted! πmaxlenβ the maximum number ofwchar_tto compare.
fr fr, do not pass NULL here. she said what she said. π
β RETURN VALUE β
- returns less than zero if
str1is "less than"str2 - returns greater than zero if
str1is "greater than"str2 - returns zero if the strings match exactly
π§ THREAD SAFETY π§
it is safe to call this function from any thread. yes bestie, she's flexible like that. π
π AVAILABILITY π
this function is available since SDL 3.2.0. iconic behavior honestly.
and that's the whole page, no notes π
sign-off time: this lil manual page comes from the Simple Directmedia Layer crew, sitting pretty at SDL 3.4.18, and it's dated the same as SDL_wcsncmp(3) β so yeah, go forth and compare those wide strings responsibly, bestie. mwah π«Άβ¨π
π¦ 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