SDL_strcasestr(3)
π SDL_strcasestr β the "where's my substring tho" girlie π
okay bestie, so this one lives in the SDL3 FUNCTIONS lineup, and her whole personality is: find the first place a substring shows up inside a bigger string, and do it case-insensitively. no cap. π
β¨ NAME β¨
SDL_strcasestr β search a UTF-8 string for the first instance of a specific substring, case-insensitively.
β¨ SYNOPSIS β¨
#include <SDL3/SDL_stdinc.h>
char * SDL_strcasestr(const char *haystack, const char *needle);
π DESCRIPTION π
so this bad girl works with Unicode strings, using a technique called "case-folding" β and she uses it to handle the vast majority of case-sensitive human languages regardless of system locale. she's not checking your locale settings, she simply does not care. π
she can also deal with expanding values, which is the unhinged part: a German Eszett character can compare against two ASCII 's' chars and still be considered a match. like, one character eating two. iconic behavior honestly. π
but there's a notable exception, and I need you to hear me on this: she does not handle the Turkish 'i' character. human language is complicated! π
and since she's doing Unicode, she expects the strings to be well-formed UTF-8 β not just a null-terminated string of arbitrary bytes. any bytes that aren't valid UTF-8 get treated as Unicode character U+FFFD (REPLACEMENT CHARACTER). which means, fr fr, two strings of random bits may turn out to match if they convert to the same amount of replacement characters. chaos! π«
π FUNCTION PARAMETERS π
haystackβ the string to search. must not beNULL. π«needleβ the string to search for. must not beNULL. π«
β RETURN VALUE β
returns a pointer to the first instance of needle in the string, or NULL if it wasn't found. that's it, that's the tea. π
π§ THREAD SAFETY π§
it is safe to call this function from any thread. go wild, multithreaded bestie, she can hang. π₯
π AVAILABILITY π
this function has been available since SDL 3.2.0. she's not new-new, but she's not ancient either. β¨
and that's the whole page, bestie!! π¦ this one came straight from Simple Directmedia Layer, version SDL 3.4.18, and it's the SDL_strcasestr(3) page β go forth and case-fold responsibly ππΈπ
π¦ 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