std::wcscpy(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::wcscpy(3) πŸ’–

okay so this is the std::wcscpy(3) page, bestie, and it comes from the C++ Standard Libary (their spelling, not mine πŸ’€). It's giving "copy a wide string" energy, and we're gonna get into it.

✨ NAME ✨

std::wcscpy β€” literally std::wcscpy. That's the name. No notes. πŸ’…

🌸 Synopsis 🌸

Defined in header <cwchar>:

wchar_t* wcscpy( wchar_t* dest, const wchar_t* src );

okay so what it does: it copies the wide string pointed to by src β€” including the terminating null wide character β€” into the wide character array pointed to by dest. slay.

⚠️ If the strings overlap, the behavior is undefined. bestie. do not overlap them. that is not the move. 😭

πŸŽ€ Parameters πŸŽ€

  • dest β€” pointer to the wide character array to copy to.
  • src β€” pointer to the null-terminated wide string to copy from.

πŸ’… Return value πŸ’…

It returns dest. that's it, that's the whole return value. iconic. ✨

πŸ¦‹ Example πŸ¦‹

The page literally says // Run this code, so go off:

        #include <clocale>
        #include <cwchar>
        #include <iostream>
        #include <memory>

        int main()
        {
            const wchar_t* src = L"犬 means dog";
        //  src[0] = L'η‹—'; // can't modify string literal
            auto dst = std::make_unique<wchar_t[]>(std::wcslen(src) + 1); // +1
       for the null
            std::wcscpy(dst.get(), src);
            dst[0] = L'η‹—';
            std::setlocale(LC_ALL, "en_US.utf8");
            std::wcout.imbue(std::locale(""));
            std::wcout << src << '\n' << dst.get() << '\n';
        }

🌈 Output 🌈

犬 means dog
η‹— means dog

πŸ¦‹ See also πŸ¦‹

  • wcsncpy β€” copies a certain amount of wide characters from one string to another. (function)
  • wmemcpy β€” copies a certain amount of wide characters between two non-overlapping arrays. (function)
  • strcpy β€” copies one string to another. (function)
  • C documentation for wcscpy.

πŸ’– source: http://cppreference.com β€’ version/date: 2024.06.10 β€’ page: std::wcscpy(3) πŸ’–

πŸ“¦ where this page comes from