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. NULL is not permitted! πŸ™ˆ
  • str2 β€” the second string to compare. NULL is not permitted! πŸ™ˆ
  • maxlen β€” the maximum number of wchar_t to compare.
fr fr, do not pass NULL here. she said what she said. πŸ’€

⭐ RETURN VALUE ⭐

  • returns less than zero if str1 is "less than" str2
  • returns greater than zero if str1 is "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