SDL_wcslcpy(3)

πŸ’– SDL_wcslcpy πŸ’–

okay bestie, welcome to the SDL_wcslcpy(3) page, part of the SDL3 functions crew ✨ this one is Copy a wide string, and she is lowkey iconic for it πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

size_t SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);

like, that's the whole vibe. three args, one return, no drama πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• this function copies maxlen - 1 wide characters from src to dst, and then appends a null terminator. that's it. that's the whole job. she's a copy girlie and she knows it πŸ’–

⚠️ <red>BIG ONE: src and dst must not overlap.</red> ⚠️ like, not even a little. don't do it. no cap πŸ™ˆ

and if maxlen is 0? bestie, nothing happens. no wide characters are copied and no null terminator is written. it's giving "I'm not doing that" energy πŸ’€ zero. nada. the function just sits there.


✨ FUNCTION PARAMETERS ✨

  • dst β€” the destination buffer, the place where the copies go 🏠 she must not be NULL, and she must not overlap with src. that's the rule, fr fr.
  • src β€” the null-terminated wide string to copy. the source material, the main character πŸ‘‘ must not be NULL, and must not overlap with dst. (yes we said it twice, because it matters twice 🫢)
  • maxlen β€” the length (in wide characters) of the destination buffer. it's how much room dst has, and the function respects it religiously 🧚

🌈 RETURN VALUE 🌈

she hands you back the length (in wide characters, excluding the null terminator) of src. so like, how long the source was β€” not how much got copied. don't get it twisted bestie 😭


πŸ’œ THREAD SAFETY πŸ’œ

it is safe to call this function from any thread. yes queen, multi-threaded, unbothered, moisturized, in her lane πŸ’…βœ¨


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. if your SDL is older than that... she doesn't exist yet, sorry babe πŸ’”


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_wcslcat(3) β€” the append version, if you're feeling concatenate-y πŸŽ€

okay that's the page!! and just so you know where all this came from: it's from Simple Directmedia Layer, shipped as SDL 3.4.18 🌸 so yeah, that's the version, that's the source, and the doc header says SDL_wcslcpy(3) up top and SDL_wcslcpy(3) again down at the bottom, because symmetry is also iconic πŸ¦‹βœ¨ bye bestie, go copy a wide string responsibly πŸ’–

πŸ“¦ where this page comes from