SDL_wcstol(3)
π SDL_wcstol π
okay bestie, welcome to SDL3 FUNCTIONS β today's main character is SDL_wcstol, and she's here to pull a whole long out of a wide string. yes, a wide string. wchar_t girlies, this one's for you π«Ά
β¨ NAME β¨
SDL_wcstol β parse a long from a wide string. that's it, that's the whole job, and she does it flawlessly π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
long SDL_wcstol(const wchar_t *str, wchar_t **endp, int base);
π¦ DESCRIPTION π¦
so here's the vibe. if str starts with whitespace, those whitespace characters get skipped before she even attempts to parse the number. like, she's not gonna be bothered by your leading spaces, she's chill like that β¨
and if the parsed number does not fit inside a long? no problem, no crash, no drama β the result gets clamped to the minimum and maximum representable long values. she keeps it in range, periodt π
π FUNCTION PARAMETERS π
strβ the null-terminated wide string to read. Must not beNULL. fr fr, do not passNULLhere, that's not the move πendpβ if it's notNULL, the address of the first invalid wide character gets written to this pointer. i.e. the very next character after the parsed number β that little marker of where she stopped reading. iconic behavior honestly πbaseβ the base of the integer to read. supported values are0and2to36inclusive. and if you pass0, the base gets inferred from the number's prefix:0xmeans hexadecimal,0means octal, and decimal otherwise. she reads the room π
π RETURN VALUE π
returns the parsed long, or 0 if no number could be parsed. zero. nada. nothing. that's your signal that she found nothing to snack on π
π§ 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. if you're on anything older, bestie, it's simply not there π
πΈ SEE ALSO πΈ
lowkey reminder:strmust not beNULL, and the number gets clamped rather than overflowing. no undefined behavior shenanigans here, just tidy clamped vibes π
and that's the whole page, bestie!! brought to you by Simple Directmedia Layer β this is SDL 3.4.18, SDL_wcstol(3), mwah, love u, go parse something wide π
β¨
π¦ 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