SDL_wcsnstr(3)
β¨ SDL_wcsnstr β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages π this one is SDL_wcsnstr and she's lowkey a baddie: she searches a wide string, but only up to n wide chars, for the first instance of a specific substring. π
πΈ NAME πΈ
SDL_wcsnstr β search a wide string, up to n wide chars, for the first instance of a specific substring. slay. π¦
π SYNOPSIS π
#include <SDL3/SDL_stdinc.h>
wchar_t * SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen);
β¨ DESCRIPTION β¨
okay so the search stops the moment one of these three things happens, and you gotta know all three:
- it finds the substring you asked for π₯
- it hits a null terminator value that ends the string π
- it has examined
maxlenwide characters π
and the cute part?? it is possible to use this function on a wide string without a null terminator. no terminator, no problem, we just count. πββοΈ
heads up bestie, this looks for strings of _wide characters_, not _codepoints_. so it's legal to search for malformed and incomplete UTF-16 sequences. it's giving raw and unbothered. π«Ά
π FUNCTION PARAMETERS π
haystackβ the wide string to search. Must not beNULL. like literally do not. πneedleβ the wide string to search for. Must not beNULL. same energy, don't do it. πmaxlenβ the maximum number of wide characters to search inhaystack. that's the whole point of then, iykyk. β¨
π RETURN VALUE π
Returns a pointer to the first instance of needle in the string, or NULL if not found. that's it, that's the vibe check. π
π THREAD SAFETY π
It is safe to call this function from any thread. fr fr, any thread, she does not care. π
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on something older... bestie. upgrade. π
and that's the whole page, periodt. this lil gem lives in Simple Directmedia Layer, SDL 3.4.18, and it's SDL_wcsnstr(3) in the manual, 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